I am having an issue when the game is restarted after the player is destroyed, any help I can get with it?

void OnCollisionEnter( Collision other)
{
if(other.gameObject.tag == “lethal”)
{
Destroy (gameObject );
GM.zVelAdj =0;
Instantiate (boomObj,transform.position,boomObj.rotation);
GM.lvlCompStatus =“Fail”;
}

	}

this code is in the player script.
and in GM i have this code.

 ![`timeTotal += Time.deltaTime;

		if (lvlCompStatus == "Fail") 
		{
			waittoload += Time.deltaTime ;
            
		}
		if(waittoload >2)
		{
			Application.LoadLevel("LevelComp");  
		}`][1]

Now i have three scene 1 is main menu which has play and quit button.
2 is the game in which the all the scripts are interlinked.
3 is level comp scene which has some scores counts and restart and quit button.

when player finishes the game by reaching the endpoint. after that if i restart then it runs fine.

but if the player is destroyed and if i restart the game. then the camera doesnt move and the game stops in may be 2 or 3 seconds and loads the level comp scene.
camera movement is sync with the player movement.

void Update () 
{
	GetComponent <Rigidbody> ().velocity = new Vector3 (0,GM.vertVel,4*GM.zVelAdj);
}

as you can see in the images the problem .
so how can i reset every thing for the game level scene. when i restart the game.

Your code is a little hard to read, but I immediately notice that you have += Time.deltaTime. I’ve never seen that before. Normally you multiply by Time.detaTime to accurately calculate the passage of time regardless of frame rate.

I have no idea what the value of waittoload is before you add Time.deltaTime to it. I think what you really want is to add 2 to Time.timeSinceLevelLoad to come up with the wait period.

Aside from that I think your main issue is that you set lvlCompStatus to “Fail” and never reset it to anything else. Using Debug.Log() can help you determine what the value of this variable is on level load.

@Shaolin-Dave and @Ady_M Thanks you guys for looking out and replying.

As for this problem I fixed by just resetting the values of

GM.zVelAdj =0; back to GM.zVelAdj =1;
and
GM.lvlCompStatus =“Fail”; back to GM.lvlCompStatus =“”;

in the if statement of waittoload.