# Problem with walls

**URL:** <https://forum.kirupa.com/t/problem-with-walls/137382>\
**Category:** Uncategorized\
**Created:** [February 14, 2005, 5:11am UTC](https://forum.kirupa.com/t/problem-with-walls/137382 "2005-02-14T05:11:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![superNoobice](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@superNoobice](https://forum.kirupa.com/u/superNoobice)\
**Post date:** [February 14, 2005, 5:11am UTC](https://forum.kirupa.com/t/problem-with-walls/137382/1 "2005-02-14T05:11:03Z")

</div>

I need some help. I finally made my hero to not walk on the wall. But for some reason when he gets near the wall and tried to walk on the other direction, he kinda stuck. Except if my hero will walk in opposite direction from the direction he used to be.

this is the code for my hero MC:

onClipEvent(load){  
moveSpeed = 4;

}  
onClipEvent(enterFrame){  
if(Key.isDown(Key.UP)){  
this.gotoAndStop(1);  
char.play();  
this.\_y -= moveSpeed;  
}  
if(Key.isDown(Key.DOWN)){  
this.gotoAndStop(5);  
char.play();  
this.\_y += moveSpeed;  
}  
if(Key.isDown(Key.LEFT)){  
this.gotoAndStop(2);  
char.play();  
this.\_x -= moveSpeed;  
}  
if(Key.isDown(Key.RIGHT)){  
this.gotoAndStop(4);  
char.play();  
this.\_x += moveSpeed;  
}  
if(this.hitTest(\_root.map) && (Key.isDown(Key.RIGHT) ||  
Key.isDown(Key.LEFT) || Key.isDown(Key.UP) || Key.isDown(Key.DOWN))){  
moveSpeed = 0;

```
}else {
    moveSpeed = 4;
}

```

}
