Sprite rotate according to their trajectory

Get help using Construct 2

Post » Thu Mar 07, 2013 9:50 pm

How do I rotate the sprite according to the trajectory?



how do I make the sprite "follow" the trajectory = rotate according to their movement path.



     
Thanks.
B
4
Posts: 10
Reputation: 495

Post » Thu Mar 07, 2013 10:20 pm

Save the old position of the object at the end of every tick and set it's angle at the beginning of every tick to the angle from the old position to the current as calculated by the angle() expression.


EVERY TICK:
set sprite angle to angle(oldx, oldy, sprite.x, sprite.y)
set oldx to sprite.x
set oldy to sprite.y
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Thu Mar 07, 2013 11:18 pm

Alternatively have an invisible sprite "lead" as your projectile, attach the visible one to it via a physics joint, and set your angle to the invisible sprite.

Just a theory.
B
20
S
6
G
2
Posts: 157
Reputation: 3,109

Post » Fri Mar 08, 2013 3:13 pm

Thank you for answers :)

you guys could put a capx ?

thanks
B
4
Posts: 10
Reputation: 495

Post » Fri Mar 08, 2013 4:59 pm

R0J0hound

I have a problem in angle(oldx, oldy, sprite.x, sprite.y)

Unknown expression 'oldx'
B
4
Posts: 10
Reputation: 495

Post » Fri Mar 08, 2013 6:27 pm

oldx is a variable you have to create.
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990


Return to How do I....?

Who is online

Users browsing this forum: Radulepy and 6 guests