# How do I get the overall velocity (Physics)

Get help using Construct 2

### » Sat Dec 20, 2014 6:14 am

I can get the velocityX and Y but not the overall velocity.

Is the overall velocity the result of VelocityX + VelocityY?

I need it to use in the equation E= MC² or KE= 0.5 * mv². I don't know which one I use, but I need to get the energy of an object that have collided with another.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

### » Sat Dec 20, 2014 7:02 am

But there is an overall velocity in the Physics behaviour
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Sat Dec 20, 2014 12:06 pm

It seems there is not an expression for the overall velocity, well, pythagore still works:

overall velocity = (velocityX^2 + velocityY^2)^0.5
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
23
G
18
Posts: 2,123
Reputation: 17,200

### » Sat Dec 20, 2014 2:39 pm

@codah

Only in the condition to compare values. ^^

@Aphrodite

Math isn't my strong side so thank you.

Edit: @Aphrodite the same projectil with the same impulse and hiting the same spot is giving me different velocity all the time. Is it right?
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

### » Sat Dec 20, 2014 5:17 pm

Well, I was wrong. I need to use F=M.A to find the impact power. Now I need to pick the bullet's acceleration and, again, construct 2 doesn't give me that. It doesn't make sense applying physics behavior and not being able to find it's acceleration or velocity by using an expression.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

### » Sat Dec 20, 2014 10:28 pm

Aphrodite wrote:It seems there is not an expression for the overall velocity, well, pythagore still works:

overall velocity = (velocityX^2 + velocityY^2)^0.5

Aphrodite, are you sure that it's the right formula?Because it's giving me an enormous range of results (like 844 and 1452) shooting within the same distance, only changing the angle a bit.

look

First shot around 800
Second shot around 1800
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

### » Sat Dec 20, 2014 11:30 pm

I do not know why, this is the formula normally... I do not use a lot the physics behavior though
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
23
G
18
Posts: 2,123
Reputation: 17,200

### » Sat Dec 20, 2014 11:38 pm

Aphrodite wrote:I do not know why, this is the formula normally... I do not use a lot the physics behavior though

I think overall velocity is totally buggy as well and I think that @Ashley should look at it because there is a big problem here. Velocity and accelaration are essencial if you need to work with physics behavior. Would be nice from him to clarify it for us.

Edit: Also I realized that a ball that is travelling clearly faster than a ball that is bouncing a bit has lower velocity than the slowly bouncing ball just before the moment that it would stop.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

### » Sun Dec 21, 2014 6:42 pm

The equation is correct. Using impulse to launch the projectile is where the variance is.
Impulse = Force*time
and from best I can tell dt is used for time and that varies.

Try setting the velocity instead with:

velocityX=speed*cos(angle)
velocityY=speed*sin(angle)
B
98
S
36
G
132
Posts: 5,521
Reputation: 84,005

### » Sun Dec 21, 2014 8:16 pm

R0J0hound wrote:The equation is correct. Using impulse to launch the projectile is where the variance is.
Impulse = Force*time
and from best I can tell dt is used for time and that varies.

Try setting the velocity instead with:

velocityX=speed*cos(angle)
velocityY=speed*sin(angle)

Actually i'm using force but I prefer to keep things more simple. I'm not good with math and I need to build something that I can work with more easily in the future, in order to fix bugs and make adjusts. So I decided to compare different ranges of the overall velocity (intervals of 50) in the collision's moment, instead of trying to get the exactly velocity, which C2 has no expression for it. I think this way I keep things simpler and, since the mass will always be the same, the result of KE=0.5*MV² would always be in the same proportion of whatever velocity I got. I did this way and so far it's working nicely regarding to each bonus the player gets and how fast the ball hits the object. At least these bonuses is being coherent and that's my goal.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612