Page 1 of 1

How do I check a physics object's velocity at an angle

PostPosted: Thu Jul 27, 2017 2:00 pm
by TRMG
Hey there, I want to check if a physics object's velocity at an angle is greater than X, but in C2 I only found the option to do this only on the X or Y axis...

I know there must be some way of finding it out by using the separate X and Y velocities and applying some mathematical equation, but math was never my strong point =D

Re: How do I check a physics object's velocity at an angle

PostPosted: Thu Jul 27, 2017 5:28 pm
by R0J0hound
You can use a dot product to get that:

cos(angle)*sprite.physics.velocityX + sin(angle)*sprite.physics.velocityY

Re: How do I check a physics object's velocity at an angle

PostPosted: Thu Jul 27, 2017 10:01 pm
by TRMG
R0J0hound wrote:You can use a dot product to get that:

cos(angle)*sprite.physics.velocityX + sin(angle)*sprite.physics.velocityY

Awesome, thank you very much!