rotate towards angle

New releases and general discussions.

» Fri Jul 30, 2010 8:56 pm

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!"
B
3
G
4
Posts: 54
Reputation: 1,183

» Fri Jul 30, 2010 9:05 pm

You mean set angle?
B
179
S
50
G
207
Posts: 8,719
Reputation: 128,306

» Fri Jul 30, 2010 9:07 pm

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.
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

» Fri Jul 30, 2010 9:36 pm

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...
B
3
G
4
Posts: 54
Reputation: 1,183

» Fri Jul 30, 2010 10:21 pm

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
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

» Fri Jul 30, 2010 10:49 pm

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.
B
179
S
50
G
207
Posts: 8,719
Reputation: 128,306

» Fri Jul 30, 2010 11:40 pm

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
B
3
G
4
Posts: 54
Reputation: 1,183

» Sat Jul 31, 2010 12:33 am

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?
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

» Sat Jul 31, 2010 1:05 am

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)
B
3
G
4
Posts: 54
Reputation: 1,183

» Sat Jul 31, 2010 1:29 am

Nevermind, i found a rotateangle in the system expression, and used that. Its basicly what i wanted.
B
3
G
4
Posts: 54
Reputation: 1,183

Next