Easing at the end of the value is wrong
« on: November 26, 2015, 06:04:35 AM »
Hi,

I use the Sequence.Append as e.g,
Easing at the end of the value is wrong when I change "default Ease" by DOTween Utility Panel.

e.g.
Code: [Select]
void onComp()
{
    Debug.LogFormat( "onComplete {0}" , m_renderer.color.a );
}

void Start ()
{
    float liveTime = 2.0f;
    m_renderer = GetComponent<SpriteRenderer>();
    Sequence seq = DOTween.Sequence();
    seq.Append( m_renderer.DOFade( 0.2f , 0.1f ) ).SetEase( Ease.Linear );
    seq.Append( m_renderer.DOFade( 0.0f , liveTime ) ).SetEase( Ease.Linear ).OnComplete( onComp );
}

I set "default Ease" to "Unset" then printed "onComplete 0".
but, if set "default Ease" to "Linear", printed "onComplete 1.192093E-08" (Umm...!?)

Is this would be trouble ?


DOTween version:
v1.0.720   -> didn't occurs this symptom
v1.0.750~ -> occurs!!

Unity Version:
5.2.3f1

Regards,

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Easing at the end of the value is wrong
« Reply #1 on: November 26, 2015, 11:08:02 AM »
Hi,

1.192093E-08 is the equivalent of 0.0000000192093, which is practically 0. This is simply due to floating point operations, where an integer is often not truly an integer (when represented as a float), but is often just very near to it. It's the same reason why you can't compare two floats for equality in regular code.

In short, this is normal and won't be a problem at all ;)

Cheers,
Daniele

Re: Easing at the end of the value is wrong
« Reply #2 on: November 27, 2015, 01:35:45 AM »
Hi Daniele,

Thank you for your reply!

Oh, I see. Maybe that means ... It is dangerous to judgment as follows code, isn't it?

Code: [Select]
void Update ()
{
    if( m_renderer.color.a <= 0.0f )
    {   // It does not pass! never.
        GameObject.Destroy( gameObject );
    }
}

And Just out of curiosity, Is that possible just changing Default Ease?

Thanks,

y-mai

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Easing at the end of the value is wrong
« Reply #3 on: November 27, 2015, 09:06:02 PM »
Hi,

Yes, indeed it's never safe to judge floats like that. You might've noticed that, even in Unity Editor, UI elements often get stuck to 1.something-Esomething in the Inspector. Changing the ease will help, but it's a random thing, since it depends on the actual computer hardware you're running on (which influences the actual results of floating point operations).

Re: Easing at the end of the value is wrong
« Reply #4 on: November 30, 2015, 02:14:39 AM »
Hi,

Ok! I'll use "OnComplete".
Thank you for your advice.