Hey brandesign

By chance, I happened to write a post on detecting full rotations a while back.

Below is a link, and a copy of my first post in that thread.

If you get a chance to visit the link, my second post

(not included below, because it's long) goes into more detail,

My second post also has a demo capx I made showing the tracking method in action.

Here is my demo capx for angle tracking.Here is a link to my post on

tracking angle changes.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Text of my first post:(Edit) I just checked the System >> "angleDiff" expression, and it always gives a zero or positive answer, meaning it doesn't give you the direction of the change in the angle, so it won't work here.

One possible approach is to calculate the change in angle between ticks,

store that change in a running total,

and track that running total instead of tracking the objects rotation property directly.

Here is a formula that will give you the change in angle as the shortest CW or CCW rotation, and it works seamlessly across the 360-to-0 transition.

angle_delta = ( ( (

a -

b ) + 180 ) - floor( ( (

a -

b ) + 180 ) / 360 ) * 360 ) - 180

Where

a and

b are your two angles.

e.g.

a = 5, b = 355:

... ( ( (

5 -

355 ) + 180 ) - floor( ( (

5 -

355 ) + 180 ) / 360 ) * 360 ) - 180

355[/u][/b]:

... =

10a = 355, b = 5:

... ( ( (

355 -

5 ) + 180 ) - floor( ( (

355 -

5 ) + 180 ) / 360 ) * 360 ) - 180

355[/u][/b]:

... =

-10Remember, if you compare two angles with a difference greater than 180 degrees, the angles will be treated as a shorter rotation in the opposite direction.

e.g. A raw difference of +270 is treated as -90.

As long as the total distance rotated per tick is less than 180 degrees that shouldn't be a problem though.

So, to use this in place of directly tracking the object's angle property, you can do the following:

Create a custom variable "unwrapped_angle".

Every tick, get the change in angle between ticks,

angle_delta(

currentAngle ,

angleRecordedLastTick ), and add it to "unwrapped_angle".

Then you should be able to use the unwrapped_angle in place of the objects built-in angle property.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -