Angle lerp direction?

Get help using Construct 2

Post » Wed Dec 10, 2014 10:03 pm

I'm trying to create a turret arm for player that turns with lerp depending on buttons pressed. My problem is that I don't know how to change the lerp's direction from clockwise to counter-clockwise. The turret arm should rotate from pointing forward (0) to pointing straight up (270).

The command I'm using is lerp(Player_Turretarm.Angle,270, 8*dt)

I tried making the angle 270 to -90 but it just made the arm rotate nonstop like crazy.
B
21
S
7
G
4
Posts: 233
Reputation: 3,474

Post » Wed Dec 10, 2014 11:16 pm

I think you want anglelerp. For example:

Code: Select all
anglelerp(Self.Angle,TargetAngle,8*dt)


^This will lerp from the turrets current angle to the target angle. The rotation is determined by the closest angle. So:

Code: Select all
anglelerp(Self.Angle(is 0),170,8*dt)


...will rotate clockwise, because that is the shortest distance. Whereas:
Code: Select all
anglelerp(Self.Angle(is 0),190,8*dt)


...will rotate counterclockwise, for the same reason.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Thu Dec 11, 2014 1:48 am

Oh, my. It's that simple. I've completely missed the anglelerp. Thanks for the help, this fixed my problem :)
B
21
S
7
G
4
Posts: 233
Reputation: 3,474


Return to How do I....?

Who is online

Users browsing this forum: Christmas and 7 guests