Question by
takixx · Jul 22, 2018 at 06:12 PM ·
transformvelocityreset-position
Reset Position
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);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Any way to make the Rigidbody keep it's last known velocity after a jump? 1 Answer
How do I trigger a game object to move a desired distance at a desired speed? 1 Answer
Up Velocity 1 Answer
Pinball Machine. HingeJoint Flippers don't work. Ball spawns in wrong direction 0 Answers
How to move a 2D object toward the position it is pointing to? 0 Answers