Hi,
I’m using loadlevel.async to load my game from the start screen. Whilst the level is loading I would like an object to be set to active which moves from a set start to finish position - but does this depending on the progress of the loading.
(So it kind of works like a progress bar, where a 20% fill is 20% loaded level – but instead I’d like the 20% fill to mean the object has moved 20% across this set distance.
It doesn’t have to be super exact - just roughly right.
However - I’m having two problems. The first is that in my console Debug.Log(async.progress) only ever reads 0, and then 1 on loading.
(I read online that if I multiply this by 100 this would sort out the issue of it rounding the float number, but I’m still not seeing any change.
Secondly: does anyone have any pointers on how I would achieve this, I’m a bit stuck!
void OnSwipeUp()
{
StartCoroutine (LoadMainLevel());
}
public IEnumerator LoadMainLevel()
{
AsyncOperation async = Application.LoadLevelAsync(1);
float t = async.progress;
overlayTerrain.SetActive (true);
overlayTerrain.transform.position = Vector3.Lerp(startPos, endPos, t);
Debug.Log (async.progress *100f);
yield return async;
}
}
Best,
Laurien