Video : https://youtu.be/9s6EG--e8oM
//
I have set the ball to go back to its original position in relation to the outer walls. However, the
“Score” disappears. I want to do this before I reset it, how can I do it?
public class Respawn : MonoBehaviour {
private Vector3 StartPoint;
public Rigidbody2D rb;
// Use this for initialization
void Start () {
StartPoint = this.transform.position;
Rigidbody2D rb = GetComponent<Rigidbody2D>();
}
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.CompareTag("Respawn"))
{
SceneManager.LoadScene("SampleScene");
//transform.position = StartPoint;
//this.transform.position = StartPoint + new Vector3(Random.Range(-7f, 1f), -7f, 1f);
//GetComponent<Rigidbody2D>().velocity = 0;
//rb.velocity = new Vector3(-7, 1, -2);
}
}
}