--------------------------------------------------------------------------------
I am having some issues with collision detection in my upcoming game "The Guardian" and I was hoping someone here could help me out?
Sometimes the main char can get stuck in the walls and the collision isnt as accurate as I wanted. If anyone can help please reply here.
Here is the code for the collision. It is on the main character and everything that we are hitTesting is withing the walls movie clip.
onClipEvent (load) {
this._name = "hiro";
_root.RUN = 6;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (_root.Walls.hitTest(getBounds(_root).xMax, _y, true)&&_root.hiroalive && !_root.hirohurt) {
_root.pushes = true;
} else {
if (_root.pause == false and _root.attack == false &&_root.hiroalive && !_root.hirohurt) {
this._x += _root.RUN;
_root.pushes = false;
}
}
} else if (Key.isDown(Key.LEFT)) {
if (_root.Walls.hitTest(getBounds(_root).xMin, _y, true) &&_root.hiroalive && !_root.hirohurt) {
_root.pushes = true;
} else {
if (_root.pause == false and _root.attack == false &&_root.hiroalive && !_root.hirohurt) {
_root.pushes = false;
this._x -= _root.RUN;
}
}
}
if (Key.isDown(Key.DOWN)) {
if (_root.Walls.hitTest(_x, getBounds(_root).yMax, true) &&_root.hiroalive && !_root.hirohurt) {
_root.pushes = true;
} else {
if (_root.pause == false and _root.attack == false &&_root.hiroalive && !_root.hirohurt) {
_root.pushes = false;
this._y += _root.RUN;
}
}
} else if (Key.isDown(Key.UP)) {
if (_root.Walls.hitTest(_x, getBounds(_root).yMin, true) &&_root.hiroalive && !_root.hirohurt) {
_root.pushes = true;
} else {
if (_root.pause == false and _root.attack == false &&_root.hiroalive && !_root.hirohurt) {
_root.pushes = false;
this._y -= _root.RUN;
}
}
}
}