How to get a positive "speed" variable w/ physics?

0 favourites
• 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
• Hi guys. What I'm trying to do is basically calculate damage with velocity and mass (IE, throwing a ball at someone does damage based on speed and weight)

However, I quickly realized that the physics X and Y velocities can be either positive or negative while moving at fast speeds depending on direction.

Here's what I'm using:

Enemies.Health - ((MovableObjects.Physics.Mass * MovableObjects.Physics.VelocityX +MovableObjects.Physics.VelocityY) * 0.05)

Basically, I just want a way to have one "speed" variable that isn't dependent on X and Y.

• abs(MovableObjects.Physics.VelocityX) will turn a negative into a positive

Are you intending to calculate (mass*velocityX)+velocityY? or mass*(velocityX+velocityY), in which case you would need more brackets.

• Oh. It's supposed to be mass*(velocityx+velocityy).

What is "abs" exactly?

• Try Construct 3

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

Construct 3 users don't see these ads
• abs returns an absolute value, basically a polsitive number. SO if the number is -1 abs will return 1. If it is -125 abs will return 125.

• I see. Thank you guys for your help.

• 5 posts