So, I’m creating a simple game that is really similar to Flappy Bird. Most of the game is already created but I’m stuck now. I want that when the bird hits the pipes, the level resets. The thing is I want a smooth reset in a way that it seems the only thing that changed was that the next pipes disappeared. What I’m trying to say is that I want to reset the level but keep the bird position. Can someone help me? I’m using:
Application.LoadLevel(Application.loadedLevel);
to reset the game.
Edit: I only want to keep the “Y position” of course, I want the “X position” to reset
make empty game object & attach this script to it :
public class Data : MonoBehaviour {
public static Data dat; //class static so enter without getcomponent from other scripts
public Vector3 BirdPosition;
void Awake ()
{
if (dat == null)
{
DontDestroyOnLoad(gameObject);// game object will not be destroyed on scene reload
dat = this;
}
else if (dat != this)
{
Destroy(gameObject);
}
}
}
now from Bird script :
void Start(){
transform.position = new Vector3 (transform.position.x,Data.dat.BirdPosition.y,transform.position.z);
}
void Update(){
Data.dat.BirdPosition = transform.position;
}