- Home /
Can I add a respawn script to a player that is separate to the destroying player script?
Here is the 'player destroy' script,
// Use this for initialization
void Start () {
}
void OnCollisionEnter2D(Collision2D coll) {
if(coll.gameObject.tag == "obstacle") {
Destroy(GameObject.Find("Player"), 1);
}
}
// Update is called once per frame
void Update () {
}
}
I am very new to unity, any help would be appreciated!
Answer by toddisarockstar · Jan 07, 2016 at 06:13 AM
Yes you pry could. but be nice. dont destroy gameobjects when you dont have too. read this:
simply move its coordinates offscreen, out of camera view, or transparent. or if you feel really mean. simply set the object or the objects script active to false. make sure the gameobject is in a variable to bring it back!
but if you still feel like you need to Destroy Something after my answer, i would recommend saving a prefab in the inspector to recreate from. if you want to go from scratch here is a link
this works to add scripts too.
Your answer
![](https://koobas.hobune.stream/wayback/20220612055032im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
instantiate multiple gameobject of the same gameobject 2d 1 Answer
Serious performance issues 0 Answers
spawn 3 object in a row at the same time ( unity ) 1 Answer
Help with Spawning & Destroying Background Objects in 2D 2 Answers
How to spawn my gameobjects and have it disappear after i click it 1 Answer