Is there a way to get the collision point between two objects when a collision occurs on physics objects. I need the actual intersection of the two objects not just the x/y of the two objects
What do the objects represent? What do you want to happen?
I’m not aware of an expression but if the objects are simple enough you might be able to calculate the point, cast a ray or combination of both. There might also be a way to do it without knowing the point.
The object is a ball and and the other objects are any other collidable object like walls or any other shapes, I want to create a particle effect at that place where the collision happens and this could be on the ground, wall or ceiling. I have tried casting rays in all directions on collision but to get an accurate position I have to cast too many rays and a hitch occurs.
There really should be an easy way to get the collision point in gdevelop as standard as there are functions within Box2d (which I believe the gdevelop physics is based on?) to get the points of contact.
It would be a nice feature. I was testing some concepts with ray cast. There are some formulas as well but I haven’t tried them. For simple shapes, I think math is the answer.
I was testing a square and circle by casting a ray from corner to corner of the rectangle.
It was going to be too much code. I was allowing the objects to overlap I was casting a ray from both directions. So, for my test I put 4 hitboxes around the square and then on collision with a hitbox I casted a ray from a point on each end of the colliding instance.
I still think math is the way to go. It was still a neat experiment to see the collision points and might be a solution to a different problem.
I found a formula that gets the collision point between a rectangle and a circle, it’s actually a simple equation. I’m surprised. Now, this only works with a rectangle that’s not rotated but this is a starting point.
.
Try it. You can drag the circle. It kind of looks like there’s a gas leak.
That is very cool and so close to what I need. Unfourtunatly my game relies on angled rectangles so thats not quite going to work for my situation. Impressive stuff though. I did think I could maybe use the locations of the ball and the colliding object to at least reduce the ray casts I need to perform to only 180 degrees in either up down left or right orientation but I haven’t had time to implement and test it yet.