Rotate sprite toward touch

Get help using Construct 2

Post » Sat Jul 13, 2013 1:03 pm

Please see this example: https://dl.dropboxusercontent.com/u/1606950/rotate_.capx

What I would like is for the object to set its angle toward the touch, but without "jumping" (try to click on the opposite side than the arrow and you'll see what I mean).

I would like it to be smooth, there is probably an easy solution computing the initial angle of the sprite and offsetting against the touch but I really can't make it work.

Thanks for any help.
B
30
S
9
G
6
Posts: 525
Reputation: 8,329

Post » Sat Jul 13, 2013 3:16 pm

B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Sun Jul 14, 2013 12:20 pm

@ramones, thank you very much, I see now what I was doing wrong.

Appreciate it.
B
30
S
9
G
6
Posts: 525
Reputation: 8,329

Post » Thu Oct 10, 2013 5:01 pm

Sup @romones and @0plus1 !

I put together a smoother rotating version. You can control the speed of rotation using delta time (dt)

@newt thought up this formula, his math is fabulous!

is in touch
set angle to anglelerp(self.angle,angle(self.x,self.y,touch.x,touch.y),1-0.5^dt)

CAPX

There's a bit of wobble as you rotate the circle but it's good.NECROKRIEG2013-10-10 17:04:18
B
15
S
6
G
3
Posts: 87
Reputation: 4,304

Post » Fri Oct 11, 2013 12:39 am

@NECROKRIEG that's actually very nice!
In the end I decided to go with a different approach.
The issue was that touching in another angle makes the object "jump" to the new angle.
B
30
S
9
G
6
Posts: 525
Reputation: 8,329


Return to How do I....?

Who is online

Users browsing this forum: Anonnymitet, gamecorpstudio, NECRONOMICRON, plinkie and 22 guests