# Physics Angle of Motion

Get help using Construct 2

### » Tue Feb 25, 2014 12:57 pm

Does anyone know of a non-cpu intensive way of measuring a physics objects' angle of motion?

ATM I base the angle on an earlier position and compare it to a current one. However, to get this smooth it is calculating it every 0.01 seconds, and I think this may be pretty intensive.

Say for example I'm trying to 'animate' an arrow so that it launches into the sky and falls down, with the arrow head always leading the way. The thing is, I have to use physics.

Any ideas?
B
97
S
20
G
8
Posts: 1,062
Reputation: 12,725

### » Tue Feb 25, 2014 3:23 pm

This should be ok

angle(sprite.X,sprite.Y,sprite.X+Sprite.Physics.VelocityX,sprite.Y+Sprite.Physics.VelocityY)
B
34
S
9
G
3
Posts: 519
Reputation: 5,300

### » Tue Feb 25, 2014 4:44 pm

would

=atan(sprite.physics.velocityY / sprite.physics.velocityX)

work ?

(Not tested )

Edit:

Close - but no.

https://www.dropbox.com/s/b749rcrcc7si976/atan%20drag%20test.capx
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,902

### » Tue Feb 25, 2014 7:01 pm

@Katala

Thank you! This should help me greatly! I have a feeling the other way I was doing it was quite intensive.
B
97
S
20
G
8
Posts: 1,062
Reputation: 12,725

### » Tue Feb 25, 2014 7:41 pm

@Katala @AnD4D

you can lose the sprite coordinates and just have:

angle(0,0,Sprite.Physics.VelocityX,Sprite.Physics.VelocityY)
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

### » Tue Feb 25, 2014 10:25 pm

@keepee So you can! Is it worth re-exporting my project for this change? Will it make even the slightest improvement to performance?

If the answer is yes, then I will go ahead and do that.
B
97
S
20
G
8
Posts: 1,062
Reputation: 12,725

### » Thu Feb 27, 2014 3:38 pm

@AnD4D

unless you're doing it 100,000 times a tick, it will make no difference.
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

### Who is online

Users browsing this forum: Google [Bot] and 24 guests