# Collision Issues

**URL:** <https://forum.kirupa.com/t/collision-issues/309088>\
**Category:** programming\
**Created:** [May 6, 2010, 3:21pm UTC](https://forum.kirupa.com/t/collision-issues/309088 "2010-05-06T15:21:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![WhyidiE](https://avatars.discourse-cdn.com/v4/letter/w/f19dbf/32.png) [@WhyidiE](https://forum.kirupa.com/u/WhyidiE)\
**Post date:** [May 6, 2010, 3:21pm UTC](https://forum.kirupa.com/t/collision-issues/309088/1 "2010-05-06T15:21:46Z")

</div>

I know there are a few of these already but looking at some of them and trying them aren’t working out very well.

I simply want to apply a collision box on a movieclip i.e. a box, on each of the frames, or for pretty much anything that can be seen as a “physical object”. At the moment the character just walks across everthing, my team member created the character and implemented this code:

\_root.attachMovie(“character”,“char”,\_root.getNextHighestDepth());  
char.xSpeed = 0;  
char.ySpeed = 0;  
char.onEnterFrame = function() {  
if (Key.isDown(Key.UP)) {  
trace(“UP”);  
this.ySpeed = -2;  
} else if (Key.isDown(Key.DOWN)) {  
trace(“DOWN”);  
this.ySpeed = 2;  
} else {  
this.ySpeed = 0;  
}  
if (Key.isDown(Key.LEFT)) {  
trace(“LEFT”);  
this.xSpeed = -3;  
} else if (Key.isDown(Key.RIGHT)) {  
trace(“RIGHT”);  
this.xSpeed = 3;  
} else {  
this.xSpeed = 0;  
}  
if (this.xSpeed == 0 && this.ySpeed == 0) {  
this.walk.gotoAndStop(“stand”);  
}  
if (this.xSpeed\>0) {  
char.gotoAndStop(“right”);  
} else if (this.xSpeed\<0) {  
char.gotoAndStop(“left”);  
} else if (this.ySpeed\>0) {  
char.gotoAndStop(“down”);  
} else if (this.ySpeed\<0) {  
char.gotoAndStop(“up”);  
}  
this.\_x += this.xSpeed;  
this.\_y += this.ySpeed;

}

Do i place the collision code on the character, if so where is the correct place, or do i place the code in the objects actions??
