rotate towards angle

This forum is currently in read-only mode.
0 favourites
• 15 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
• I noticed there is rotate towards object and rotate towards position, but no rotate towards angle or any custom value actually. Which would be quite great indeed.

In case there is a moving object like a tank carrying a turret object on itself, by rotating the object the turret could be easily rotated aswell. Or in case you just want a lot of objects to rotate towards a specified angle, and not all of them towards a single point.

Like a platoon order : "Bitches turn left, hua march!"

• You mean set angle?

• For a tank turret to move like that you could set it up like so-

Set turret angle to Tank angle + modifier.

And yeah, set angle would cover the other one.

• yeah but set angle doesnt rotate, it just sets the angle, i mean you could rotate it by doing +1 angle every some but rotate towards is much simple...

• You are thinking too rigidly.

It may seem very uncompromising with a name like 'SET' angle.

What you need to do is reference the current value.

So always - set 'sprite.angle' to 'sprite.angle' +20 * timedelta

So you set it to itself, plus. This works with everything to by the way, when moving on the X and Y and so on.

http://dl.dropbox.com/u/1487524/Scirra/ ... xample.cap

I just whipped this up. Rotating with set angle, Rotating to a limit with set angle. And the tank turret example. Made in 0.99.91

• Theres always lerp

angle set angle lerp(.angle, newangle, 1-0.5^timedelta)

Course you'll get the barrel roll when you go from 360 to 0....

Then again you have to be careful if your using the turret behavior.

Has target inverted should help.

• What you need to do is reference the current value.

So always - set 'sprite.angle' to 'sprite.angle' +20 * timedelta

I don't know how to use this actually within one event, because it is not the same object, it needs to change its angle actually rotate based on other object.

angle set angle lerp(.angle, newangle, 1-0.5^timedelta)

Course you'll get the barrel roll when you go from 360 to 0....

And all i get is barrel roll all the time

• http://dl.dropbox.com/u/1487524/Scirra/ ... xample.cap

Did you have a look at my example here? Is this tank thing not what you want to achieve? How is it different? Can you give a detailed example or perhaps a cap to look at?

• yes i did look at it, but thats not the problem, if u set carmovement to your tank, and you have no control over the cannon, its shooting by itself at enemies, when there are no enemies around it should rotate back into neutral position(tank angle)

• Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Nevermind, i found a rotateangle in the system expression, and used that. Its basicly what i wanted.

• I had a look at rotateangle also, couldn't get it to work right.

Glad you found a solution, i managed to make my system work in the mean time, so i may as well still post to mention that.

http://dl.dropbox.com/u/1487524/Scirra/ ... xample.cap

• Well, your system is ok, but this takes only one event for rotating back with the rotateangle.

http://www.mediafire.com/?l7lgltjdgrm733b

• It seems like i was using a value far too large in that expression.

I also like the new colour you gave my tank.

• This should show what lerp does.

http://dl.dropbox.com/u/666516/autorotate.cap

• Thanks for the lerp demo!

• 15 posts