Author Topic: How do you use animation curves?  (Read 5742 times)

Trithilon

  • Guest
How do you use animation curves?
« on: May 23, 2013, 06:53:31 PM »
OK,
I know it sounds dumb... but I don't know how to .
I am choosing Linear, EaseIn, EaseInOut etc... but it won't work at all.
Is there a flag I need to set in the tweener to enable usage of the animation curve?

If someone could type in a pseudo-code snippet. :S


I tried the following,

   void OnClick()
   {
// I even tried using TweenScale NewTweer = ... - WONT WORK :S
    UITweener NewTweener =   TweenScale.Begin(TweenMe,0.5f,new Vector3(TweenMe.transform.localScale.x * 2,TweenMe.transform.localScale.y *2,TweenMe.transform.localScale.z *2));
     // WONT WORK!       NewTweener.animationCurve = TweenMe.GetComponent<TweenScale>().animationCurve;
      
       NewTweener.animationCurve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)); // WONT WORK EITHER!
   }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How do you use animation curves?
« Reply #1 on: May 23, 2013, 08:57:35 PM »
When using an animation curve, always use "linear" as the method. Animation curve should always go from 0 to 1 on time, because 0 means "when it starts" and 1 means "when it ends", which is equal to your "duration" specified on the tween. So for example if you wanted a bounce that begins at 0, goes to 1, and ends back at 0, you'd specify 3 keys (easier to do it in inspector btw!) -- (0, 0), (0.5, 1), (1, 0), where left = time, and right = value.

Trithilon

  • Guest
Re: How do you use animation curves?
« Reply #2 on: May 24, 2013, 02:21:21 AM »
This worked when I did something like this :
But I am trying to get it to use the custom curve I have specified and it just wont work. :S Just a straight boring Linear Scaling.
   
   void OnClick()
   {
      
    TweenScale NewTweener =   TweenScale.Begin(TweenMe,0.5f,new Vector3(TweenMe.transform.localScale.x * 2,TweenMe.transform.localScale.y *2,TweenMe.transform.localScale.z *2));

   new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(0.5f, 1f), new Keyframe(1f, 0f));

//   NewTweener.animationCurve = TweenMe.GetComponent<TweenScale>().animationCurve;
      
   }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How do you use animation curves?
« Reply #3 on: May 24, 2013, 05:48:07 PM »
Set up the tween on the object at edit time, instead of via code. Disable it so that it doesn't start playing right away. In the code simply enable it in OnClick().