Collision position

0 favourites
  • 3 posts
From the Asset Store
Particles support animations, collisions, effects and etc.
  • Is there a easy way to pinpoint exactly where the collision between two sprite take place?

    Lerp would work really well but one of the sprite is growing in size from 20px to 200px and can collide with the other sprite anywhere there between.

    I'm using lerp to calculate the distance between the middle points, so when the sprite is at 200px for example, the collision is a bit offset.

    So lerp(ring.X,square.X,0.5) does work but not when the ring is at 200px size.

    I'm creating a particle effect when they collide, so it has to be at the collision X,Y position.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Your lerp system is probably about as accurate as it can be. You could try taking in to account the sizes of the objects to improve it slightly.

    Collisions don't actually occur at specific points: collisions are always regions of the objects overlapping each other, which is going to be an unusually shaped polygon rather than a point. So since collisions have an area, there's no one point you can say the collision happened at. Estimating based on the object sizes, distance apart and relative angle is the best way to go.

  • Ah brilliant, found out by using the same lerp and adding one more action.

    Moved particle at angle of the two sprites. Found out the distance by using the distance expression to calculate the length between the particle and the square. Works like a charm :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)