Collision acts strange

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Lovingsoul1337
Citizen
Posts: 61
Joined: Fri Feb 21, 2020 1:26 pm

Collision acts strange

Post by Lovingsoul1337 »

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 !
Lovingsoul1337
Citizen
Posts: 61
Joined: Fri Feb 21, 2020 1:26 pm

Re: Collision acts strange

Post by Lovingsoul1337 »

if you need more to see of my class here is my complete player class.

https://pastebin.com/QxHBP6Yq
RNavega
Party member
Posts: 385
Joined: Sun Aug 16, 2020 1:28 pm

Re: Collision acts strange

Post by RNavega »

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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 13 guests