- Home /
Dont Destroy on Load is Destroying!
I am very confused. I just have the simple script:
function Awake () {
DontDestroyOnLoad (transform.gameObject);
}
attached to my gameObject, but the object still gets destroyed on the next level! What is going on?
Answer by AnXgotta · Aug 12, 2012 at 04:09 PM
Possibly just try:
function Awake(){
DontDestroyOnLoad(gameObject);
}
Going through the transform to get the gameObject might be causing strange behavior. I know this is how it's done in the example but I've always done it this way and it works fine.
Also, be sure that no other scripts are accidentally destroying the object or it is destroying itself. Seems obvious but sometimes things like this get overlooked.
Your answer
Follow this Question
Related Questions
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
Destroy box and show image 2 Answers
Two objects are placed at the same place. How to destroy one and keep another? 1 Answer
Co Routine 2 Answers
How to Instantiate object on mouse click at mouse cursor position? 1 Answer