Separate 2 colliding objects.

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
ddabrahim
Party member
Posts: 183
Joined: Mon May 17, 2021 8:05 pm
Contact:

Separate 2 colliding objects.

Post by ddabrahim »

Hi all!

I have implemented HardonCollider in my project to allow me to rotate colliders and detect collision with the rotation taken in to account.
However, it is introduced me to a new challenge when I try to detect where exactly the collision occurs and move object away from an other.

I have attached a screenshot of the scenario I am trying to solve. The red rectangle is the collider I think it is clearly visible where the collision occur between the two object. The object is moving toward the green arrow and the task I am trying to solve is to allow the object to continue to move toward the green arrow but at the same time also move it away toward the black arrow away from the point of collision:
collision.png
collision.png (25.61 KiB) Viewed 5608 times
HardonCollider seems to not include any way to know where exactly the collision accour and without this information I have no idea how to find the angle to move the object away to.

Is there any library that could potentially take the polygons and help me calculate the angles, point of collision?
Or is there anyone who could point me in the right direction how to solve this with a math formula or any library?

I would appreciate any help.

Thank you.
User avatar
darkfrei
Party member
Posts: 1181
Joined: Sat Feb 08, 2020 11:09 pm

Re: Separate 2 colliding objects.

Post by darkfrei »

Sliding point along the line:

viewtopic.php?p=255011#p255011
Image
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
ddabrahim
Party member
Posts: 183
Joined: Mon May 17, 2021 8:05 pm
Contact:

Re: Separate 2 colliding objects.

Post by ddabrahim »

Seems exactly what I needed.
Thanks a lot for the quick reply :)
Post Reply

Who is online

Users browsing this forum: No registered users and 48 guests