(S) How do I get an object's collision velocity?

0 favourites
  • 6 posts
  • Hey there, I've got an egg (with physics) in my game and I want it to crack when it hits the floor to fast.


    I can use this formula to calculate the velocity at a certain angle: cos(ANGLE)*Egg.physics.velocityX + sin(ANGLE)*Egg.physics.velocityY

    but I don't know how to get the collision point so that I can convert it into an angle and then compare it...

    Do you guys know how to do this?


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Do you need to be able to determine if the egg will break before it actually reaches the floor?

    If not, why can't you compare egg's velocity at the moment of collision?

    Edit: Looks like physics velocity changes on collision. Still, you can save egg's velocity in a variable on every tick. When collision happens, use velocity value from the previous tick.

  • [...]why can't you compare egg's velocity at the moment of collision?[...]

    You mean the overall velocity?

    Well if the egg were to move really fast towards the right and only slightly downward and it would hit the ground (that is underneath the egg), it would still break.

    I want it to break only if it's velocity at the angle of the collision is too high.

  • Well, I guess you can only compare VelocityY and ignore VelocityX.

  • dop2000

    That wouldn't work either in a situation like this:

    The egg could also hit the ground object from the right or left.

    I also can't hard-code an angle to check against for each ground object because the egg could hit the ground from multiple angles...

    I saw another forum post where someone else found a way to do this by attaching some small sprites around the object and checking if they overlap with another object. If they did, then I could use their position for a rough estimate for where the collision took place.

    I'll try this method and see if it works in my case too.

  • dop2000 Hey, that method worked great.

    Thanks for your help.

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