chesnutcase
chesnutcase

Reputation: 522

How do I create an object that already exists in the Hierarchy in Unity C#

I have a character that when it touches another object(lava), it is destroyed. Upon death, there will be a GUI that creates a respawn button, but how do I re-create the player object? I destroyed the object with Destroy(collision.gameObject);

Upvotes: 0

Views: 354

Answers (2)

Wesley Vrancken
Wesley Vrancken

Reputation: 474

Instantiate should do the trick.

Upvotes: 0

Jamie Syme
Jamie Syme

Reputation: 538

The way I would approach your problem would not be to destroy the player when it touches the lava, but rather deactivate the object. Then, when the user clicks the respawn button you would simply activate the object again (but make sure to take him out of the lava first).

This might help for the code-side of things.

Upvotes: 1

Related Questions