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

From the Asset Store
Object Destruction Sounds
\$4 USD
60% off 112 High-Quality destruction sounds for videogames
• 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 ?

• ## Try Construct 3

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

Construct 3 users don't see these ads
• 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)

• 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 :)

• 4 posts