How to check if attribute has been increased or decreased.
For example, rotation of an actor follows my mouse position, and after releasing the mouse I want to know, which direction the actor was rotating - clockwise or counterclockwise? Has rotation attribute been increased or decreased? Any ideas?
Answers
Timer, after X second
Rule if attribute is bigger than X
Put your rules here.
Consider:
PrevAngle = 359
Rotates 2 degrees
NewAngle = 1
PrevAngle < NewAngle? False
I'm actually trying to solve something similar to this right now. Ideas welcome.
difference = ((difference +180)%360)-180
This also has the nice effect of telling you if the difference is clockwise or not. (The result will be positive or negative.)
Are you sure that formula is correct?
Care to give an example of its usage?
Make two attributes:
self.oldRotation (type = real)
self.difference (type = real)
When mouse is down
-- Change Attribute: self.oldRotation to self.Rotation
-- Change Attribute: self.difference To: vectorToAngle( game.Mouse.Position.X - self.Position.X , game.Mouse.Position.Y - self.Position.Y )- self.Rotation
-- Change Attribute: self.difference To: (( self.difference +180)%360)-180
-- Interpolate Attribute: self.Rotation To: selfRotation + self.difference
I just had a wave of nostalgia -- discovering this handy little trick was one of my first posts to the gamesalad forum:
http://forums.gamesalad.com/discussion/28229/be-an-angel-fix-my-angle-stop-rotating-the-long-way-round-to-a-given-angle/p1
This should simplify several challenges you might be having with controlling the speed and direction of an orbiting rocket.