I’m working with a randomly moving MC, and now it looks good
exept the collisions with the level.
When it hits the level it gonna rotate and go another way.
I don’t want it go through the walls.
Please help!
onClipEvent (load) {
xx = -(Math.cos(this.ro._rotation*(Math.PI/180)))*speed;
yy = -(Math.sin(this.ro._rotation*(Math.PI/180)))*speed;
this.ro._rotation = random(360);
radie = 9;
speed = 2;
rot = random(30)-random(30);
}
onClipEvent (enterFrame) {
rot *= 0.9;
if (rot == 0) {
rot = random(30)-random(30);
}
xx = -(Math.cos(this.ro._rotation*(Math.PI/180)))*speed;
yy = -(Math.sin(this.ro._rotation*(Math.PI/180)))*speed;
_x += xx;
_y += yy;
this.ro._rotation += rot;
/*------------------------------DOWN HERE------------*/
for (i=0; i<radie*2; i++) {
if (_root.coll.hitTest(_x, _y-radie+i+yy, true)) {
this.ro._rotation -= (this.ro._rotation/2);
rot = random(30)-random(30);
if (_rotation == 0) {
this.ro._rotation = random(360);
}
}
if (_root.coll.hitTest(_x-radie+i+xx, _y, true)) {
this.ro._rotation -= (this.ro._rotation/2);
rot = random(30)-random(30);
if (_rotation == 0) {
this.ro._rotation = random(360);
}
}
}
if (_root.coll.ground.hitTest(_x, _y, true)) {
this.ro._rotation -= (this.ro._rotation/2);
rot = random(30)-random(30);
}
}