hi !
can someone please help me with a simple aabb collision system where collision with multiple tiles and corners can happen ?
i want if i hi a wall that velocity stop according from which side i collided and then that i can run smoothly along the wall directly.
but if i do now for example running into a wall from top to down and continue pressing the down button and then press 1 time d for right
the player fast speed to the left...
you know eventually why ?
https://pastebin.com/XySJfCAJ
thanks in advance !
Collision acts strange
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Citizen
- Posts: 61
- Joined: Fri Feb 21, 2020 1:26 pm
Re: Collision acts strange
Instead of zeroing out the velocity and changing the position of the player when they collide with something, how about changing only the velocity?
If there's an overlap, then the velocity should be reduced to make the player move only as much as needed to touch the obstacle.
So if the player is moving by X on the horizontal axis and there's a collision with an overlap of 5 pixels if they move by that velocity, then reduce the velocity by that overlap.
That is, avoiding changing the position of the player directly, and only resolving collision overlaps through the velocities and forces being applied to the player.
If there's an overlap, then the velocity should be reduced to make the player move only as much as needed to touch the obstacle.
So if the player is moving by X on the horizontal axis and there's a collision with an overlap of 5 pixels if they move by that velocity, then reduce the velocity by that overlap.
That is, avoiding changing the position of the player directly, and only resolving collision overlaps through the velocities and forces being applied to the player.
Who is online
Users browsing this forum: Google [Bot] and 6 guests