Physics - How do I get Angle of Motion?

Get help using Construct 2

Post » Sat Nov 22, 2014 4:40 pm

I'm trying to get the angle of motion of a physics object.

I've tried:
Code: Select all
angle(0,0,sprite.Physics.VelocityX,sprite.Physics.VelocityY)


But sometimes I get a negative number. Am I doing this correctly? Or is there something I need to do to convert the negative?
B
34
S
10
G
5
Posts: 165
Reputation: 6,697

Post » Sat Nov 22, 2014 6:53 pm

I noticed this recently as well. Does the physics object have any joints on it? I'm wondering if the joints are affecting the value.
Perhaps you can record the last position it was at (in the previous event cycle), and calculate the current trajectory based on that?
B
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Sat Nov 22, 2014 6:57 pm

No joints at the moment, no.
B
34
S
10
G
5
Posts: 165
Reputation: 6,697

Post » Sat Nov 22, 2014 7:53 pm

Hi @Taurian Your formula looks ok.
Have you tried adding 360 if the result is negative? Would the angle look about right?
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Sat Nov 22, 2014 7:55 pm

Negative angles are usually ok as well but, if you need to you can use this.
Code: Select all
(angle(0,0,Sprite.Physics.VelocityX,Sprite.physics.velocityY)+360)%360
B
34
S
9
G
3
Posts: 517
Reputation: 5,246

Post » Sat Nov 22, 2014 7:56 pm

Hi @Katala, yes that's kinda what I was getting at.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Sat Nov 22, 2014 8:39 pm

@Katala, thanks that did it!
Epic Space Online - Google it!
B
34
S
10
G
5
Posts: 165
Reputation: 6,697


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 23 guests