- Home /
Question by
akihirohosogoe0610 · Apr 19 at 11:22 AM ·
pause game
How to pause and complete the rest movement when unpaused?
This script is attached to the gameobject that I want to pause. The object is to complete a (dis)distance movement. I want to make it able to complete the rest movement when resumed.
For example:
dis = 1
move 0.5
pause
resume
move 0.5
float count = 0;
Vector3 origin = transform.localPosition;
while (count < sec)
{
if(Gs == GameState.Running)
{
transform.localPosition = origin + gameObject.transform.rotation * new Vector3( 0, 0, -count / sec * dis);
yield return new WaitForEndOfFrame();
count += Time.deltaTime;
}
}
Comment
How is sec
being set/assigned?
Since count
is incremented by Time.deltaTime, that part should already be taken care of for you (it will effectively stop increasing when the time scale is set to 0).
I get the feeling the problem lies with sec
, since that's the only other variable your while loop hinges on.