Hey all, trying to figure something out here, I've got a simple room with two enemies moving next to each other between two walls.
The first one hits a wall, it bounces back, hits the other and then the problem occurs, for some reason at the exact point of collision they both move one pixel left, one pixel right, and then reverse direction like they're supposed to. It's a bit hard to notice I guess, my brother couldn't see anything wrong with the way they were moving but it seems like a really big and obvious thing to me.
Here's the code for their step event:
if place_meeting(x + 1, y, par_solid) ^^ place_meeting(x - 1, y, par_solid) {
hspd *= -1; // Reverse horizontal direction
}
Hspd is a custom variable used for their movement speed, they have the par_solid object as their parent just for testing, so they'll bounce off each other the same way they'd bounce off of a wall. The only other code involved is establishing [hspd = 1;] in the create event and adding [x += hspd;] in the step event.
Anyone have any ideas as to how to fix this? I've tried a couple other ways of detecting the collision and this was the best one so far.
Edit: Solved thanks once more to Niek.