- Home /
Restarting the game Error
The game that I am creating is kind of like a 3d dino game with the player dodging the fences that they are racing towards. I wanted to make it so that whenever they push R the game would restart, and I got that to work but whenever the player pushes R, the players jump Hight for some reason starts to drop every time that they push R. Any ideas what might be going on? This is the code that I am using to restart:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class Restart : MonoBehaviour {
void Start()
{
}
// Update is called once per frame
[System.Obsolete]
void Update()
{
if (Input.GetKeyDown(KeyCode.R))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
}
Thanks!!
Answer by adityarocks123456 · May 10, 2021 at 02:54 PM
Have you added this scene in the build settings ?
Your answer
Follow this Question
Related Questions
change to glow texture on mouse click 0 Answers
I just discovered unity, How can i get started? 1 Answer
How to save a single object 1 Answer
My code dont work on a MLAgents, Unity 2020.2.7f 0 Answers
Terrain into Model 0 Answers