How do I set sprite angle to angle of physics motion

Get help using Construct 2

Post » Mon Aug 03, 2015 4:17 pm

Hi everyone,

probably an easy one, but can someone tell me how to set the angle of a sprite to the angle of its motion? By that I mean so the sprite is always 'facing' the direction it is traveling in (like a rocket).

Thanks!
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Mon Aug 03, 2015 4:55 pm

set angle of sprite to

angle(0,0,self.Physics.VelocityX,self.Physics.VelocityY)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Tue Aug 04, 2015 4:17 pm

RamPackWobble wrote:set angle of sprite to

angle(0,0,self.Physics.VelocityX,self.Physics.VelocityY)


That's exactly what I was looking for, thank you!

Just one question, I understand the self.Physics.VelocityX,self.Physics.VelocityY, but why put 0,0 in there first? And how did you work out you needed to do that? :P

Thanks again for your help!
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Tue Aug 04, 2015 6:54 pm

by standing on the shoulders of giants :)

angle(x1, y1, x2, y2) Calculate angle between two points

self.physics.velocityx and self.physics.velocityy is the velocity (speed) in pixels / second so for example if velocityx is 4 and velocityy is 3 then angle(0,0,4,3) is going to give you the angle from 0,0 to 4,3 (30 degrees ?)

Hope this helps ?
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Wed Aug 05, 2015 10:46 am

RamPackWobble wrote:by standing on the shoulders of giants :)

angle(x1, y1, x2, y2) Calculate angle between two points

self.physics.velocityx and self.physics.velocityy is the velocity (speed) in pixels / second so for example if velocityx is 4 and velocityy is 3 then angle(0,0,4,3) is going to give you the angle from 0,0 to 4,3 (30 degrees ?)

Hope this helps ?


Thank you very much for taking the time to explain! Yeah that helped a lot, much appreciated :D.
B
13
S
6
Posts: 130
Reputation: 1,553


Return to How do I....?

Who is online

Users browsing this forum: wizdigitech, Zamargo and 14 guests