Closed GoogleCodeExporter closed 8 years ago
Hi,
your test is done wrongly because of these reasons:
1. You're starting the Timer immediately at startup, which means that it will
count also all Unity's own initialization methods, which add up and result in a
fake end time. Try instead to make a coroutine out of Start, yield return a new
WaitForSeconds(1), and only then start the tween and the timer
2. the Timer should start the row AFTER you create a tween, otherwise it will
take into account also the tween creation time (which, considering it's the
very first tween, means HOTween will also have to auto-initialize and thus take
slightly longer than usual to create the tween)
3. Stopwatch and Unity's internal timers can have slightly different values
If you do the test correctly you'll see that you'll get results that vary
between 5 and 16 MS, which is perfectly normal considering that FixedUpdate is
called every 20 MS. Consider also that Unity "tries" to call FixedUpdate every
20 MS, but that doesn't mean it truly happens at that interval (it actually
NEVER happens at that interval), even if fixedDeltaTime is always reported to
be the same.
Original comment by daniele....@gmail.com
on 1 Aug 2014 at 8:12
I did the test like you said and I get results that vary between 3 and 16 ms.
If this is an expected result then there is no bug, thanks for your time.
This is the test made correctly:
using UnityEngine;
using System.Collections;
using Holoville.HOTween;
public class Hottweentest : MonoBehaviour
{
public float Position = 0f;
private System.Diagnostics.Stopwatch Timer;
void Start () {
Timer = new System.Diagnostics.Stopwatch();
StartCoroutine(TestHotTween());
}
private IEnumerator TestHotTween()
{
yield return new WaitForSeconds(1);
HOTween.To(this, 1f, new TweenParms().
Prop("Position", 5f).
SpeedBased().
UpdateType(UpdateType.FixedUpdate).
OnComplete(ShowTime)
);
Timer.Start();
}
private void ShowTime()
{
Debug.Log(Timer.ElapsedMilliseconds);
Timer.Stop();
Timer.Reset();
}
}
Original comment by fer...@gmail.com
on 1 Aug 2014 at 9:35
Perfect :) By the way, if you're curious, you could try using a stopwatch to
check when each Unity's FixedUpdate is truly called. You'll see that it tries
to keep a 20 MS average, meaning that if one is called after 30 MS the next
update will try to be called after 10 MS.
Original comment by daniele....@gmail.com
on 2 Aug 2014 at 8:13
Thanks I didn't know that, I guess there is no workaround for this because
using a non unity framework loop can cause issues with the thread safe
restrictions.
Original comment by fer...@gmail.com
on 2 Aug 2014 at 12:35
Yup. Though who knows, maybe something will change with Unity 5.
Original comment by daniele....@gmail.com
on 2 Aug 2014 at 1:18
Original issue reported on code.google.com by
fer...@gmail.com
on 1 Aug 2014 at 7:21