Jump to content
Search Community

Getting exact value for tweened object rotation in runtime?

vvuk test
Moderator Tag

Recommended Posts

Hi,

 

I have a simple tween:

 

TweenLite.to(_mainWheel.wof, _speed, {rotation:(_suspension*2) + (_prizeIndex * _pieAngle), immediateRender:true, useFrames:false, ease:Expo.easeOut, onUpdate:checkPosition,  onStart:removeEventListeners, onComplete:mainAnimationFinished });

 

 

So, I`m trying to catch it`s rotation angle using checkPosition which is called onUpdate.

 

private function checkPosition():void
   {
  trace (_mainWheel.wof.rotation);
   }

 

Is there any change I get this value accurate?

 

I`m receiving

 

 

-160

-73

15

74

134

-165

-119

-68

-28

5

39

75

110

139

173

-157

-124

-96

-74

 

AS you can notice, first traced value is:

 

-160

 

and second:

-73

 

which is more than double difference between that two.

 

I simply need that to be accurate so if my start roration position is 0, when I run rotation tween and trace it value i get:

 

0

1

2

3

...

177

178

179

180

-180

-181

...

 

Anyway, this problem happens only when I run my tween really fast, so I presume this is only because script cannot render rotation that accurate.

 

What would you suggest as solution for this problem?

Thanks

Link to comment
Share on other sites

By default TweenLite uses an ease:Quad.easeOut which would explain the big jump at the beginning. Tweens that ease out start fast and end slow.

use ease:Linear.easeNone to enforce a constant rate of change.

 

Still, as GreenSock noted here: http://forums.greensock.com/topic/6186-tweenlite-cant-get-right-rotation-property-from-a-rotating-object/ you probably aren't going to hit every integer increment due to the nature of Flash processing frame updates with variance.

Link to comment
Share on other sites

And to be clear, the values you are getting are EXTREMELY accurate. I really think you're misunderstanding some key concepts in scripted animation (which are not unique to GreenSock tools by the way) and you'll save yourself a lot of frustration if you re-read the answer I gave you here: http://forums.greensock.com/topic/6186-tweenlite-cant-get-right-rotation-property-from-a-rotating-object/page__p__22071#entry22071

 

Please let us know if that explanation was unclear or if you have any other questions at all about why the values are (and should be) reporting the way they are currently. If your goal is to make the engine conform to your ideal scenario of only incrementing by one integer on each update, you will incur massive performance penalties and create a ton of waste but if you spend the time to understand the fundamentals and why things work the way they do, I think you'll be able to leverage that knowledge to create a far superior solution.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...