# RPG Moving character with NPC's

**URL:** <https://forum.kirupa.com/t/rpg-moving-character-with-npcs/187741>\
**Category:** programming\
**Created:** [May 2, 2006, 12:33am UTC](https://forum.kirupa.com/t/rpg-moving-character-with-npcs/187741 "2006-05-02T00:33:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zipperdeaf](https://avatars.discourse-cdn.com/v4/letter/z/58956e/32.png) [@zipperdeaf](https://forum.kirupa.com/u/zipperdeaf)\
**Post date:** [May 2, 2006, 12:33am UTC](https://forum.kirupa.com/t/rpg-moving-character-with-npcs/187741/1 "2006-05-02T00:33:50Z")

</div>

Im using the RPG game tutorials code for moving my character:  
//////////////////////////////////////////////  
onClipEvent (load) {  
s = 3;  
b = this.getBounds(this);  
function move(x, y) {  
if (\_root.stopwalk == false) {  
if (!\_root.hit.hitTest(\_x+x+b.xmin+1, \_y+y+b.ymin+1, true)) {  
if (!\_root.hit.hitTest(\_x+x+b.xmax-1, \_y+y+b.ymin+1, true)) {  
if (!\_root.hit.hitTest(\_x+x+b.xmin+1, \_y+y+b.ymax-1, true)) {  
if (!\_root.hit.hitTest(\_x+x+b.xmax-1, \_y+y+b.ymax-1, true)) {  
\_x += x;  
\_y += y;  
}  
}  
}  
}  
}  
}  
}  
onClipEvent (enterFrame) {  
keydown = false;  
if (\_root.stopwalk == false) {  
if (Key.isDown(Key.UP)) {  
keydown = true;  
\_root.hero.gotoAndStop(1);  
move(0, -s);  
}  
if (Key.isDown(Key.DOWN)) {  
keydown = true;  
\_root.hero.gotoAndStop(5);  
move(0, s);  
}  
if (Key.isDown(Key.LEFT)) {  
keydown = true;  
\_root.hero.gotoAndStop(2);  
move(-s, 0);  
}  
if (Key.isDown(Key.RIGHT)) {  
keydown = true;  
\_root.hero.gotoAndStop(4);  
move(s, 0);  
}  
}  
if (!keydown) {  
\_root.hero.char.stop();  
}  
}

/////////////////////////////////////

I need to figure out how to add an npc. Also if there is a better way I can have this character walk according to the art based walls its from what i see not supported with anything above flash 5.
