Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by jswart

I have over-written an entity's ' handleMovementTrace ' method. At the end of this method I call

this.parent(res);

Why is it that when I do something like this:


newRes = { 
    collision: { x: true, y: true, slope: false },
    pos: { x: 0, y: 0 }, // this is all just filler data.  The important part is the collision.
    tile: { x: 0, y: 0 }
}

this.parent(newRes);


Why is my ' newRes ' not taken into account? The entity is still able to move. Is there another way this must be done?

1 decade ago by Joncom

You could simply overwrite the entire method and not call it's parent.

handleMovementTrace: function( res ) {

	// Pretend collision occured; don't move.
	this.vel.x = this.vel.y = 0;
}

1 decade ago by jswart

Yeah that was my thought as well. I was working on 8 direction movement, in a tile-based movement setup.

The issues was that when you collide with a wall while walking in a cardinal direction, you only collide on one axis.

ie: walk up into wall. res.collision.x = false, res.collision.y = true

So when you try and walk diagonally up-left or up-right, the collision is the same as the above, and no y-axis movement is possible but x-axis movement is possible and the entity slides against the wall.

I haven't really come up with a solution yet. But I think I'm scrap-ing 8way in favor of 4way movement anyway.
Page 1 of 1
« first « previous next › last »