[Physics] How do I get the velocity value of an object that is colliding with another

0 favourites
  • 4 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hello,

    Im trying to create a damage system based on the strengt of the collisions between physics objects. One of my major problem is that whenever I want to know the velocity of an object that is colliding, I cannot get the right value.

    Here is a simplified exemple of my problem :

    When I use :

    On collision between objects A and B => Set "CollisionVariable" to ObjectA.Physics.VelocityX

    The retrieved value is the VelocityX AFTER the collision, but I want the velocity just BEFORE.

    Any Idea of how to do that ?

  • I think you need to calculate the velocity on every tick (or every 0.1s for example) and store it in a variable. And on collision use that variable.

    Also, to get the overall velocity, use this expression:

    distance(0, 0, Object.Physics.VelocityX, Object.Physics.VelocityY)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you,

    This is a solution I already tested, it works most of the time but also has some issues. I will use this if I do not find a better solution.

    To get the absolute velocity I use sqrt(Object.Physics.VelocityX^2 +Object.Physics.VelocityY^2)

    I didnt know that could use distance(x,x,x,x), thanks !

  • I didnt know that could use distance(x,x,x,x), thanks !

    It's for people who don't remember the Pythagoras theorem :)

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