Restarting movement after collision detection

Hey, not sure if this belongs in the physics forum, but here I go:

I have a problem with collision detection where I’m not able to get an object to move after it collides with another object.


//all in simpleUpdate()


if (KeyBindingManager.getKeyBindingManager().isValidCommand(“coordsUp”,true)){

strconv=strconv+.1f; //increases angle of obj1


if (KeyBindingManager.getKeyBindingManager().isValidCommand(“coordsDown”,true)){

strconv=strconv-.1f; //decreases angle of obj1




I realize the problem is that once the objects intersect, the loop stops completely, but I just don’t know how to get around it. Ideally, the conditions will allow movement to be restricted in the direction of the object, but free in all directions that there is no collision.

For example, when a player in a game runs into a wall, he cannot go through the wall, but his movement is not completely restricted in that he can back up or turn around.



Right, well I was able to figure it out on my own.

For anyone that ever finds himself in the same predicament, you must declare a variable that holds the location for the previous iteration of the movement, and set the position equal to the old one, if a collision is detected.

1 Like