- Home /
Question by
Wolf_dead_inside · Nov 22, 2020 at 10:16 PM ·
instantiateunity 2ddestroy object
The object of type 'Transform' has been destroyed not being solved even when I check if it's null
public void KillPlayer()
{
Debug.Log("Player killed");
if (this.transform != null)
{
Instantiate(playerDeathParticle, this.transform);
}
Destroy(this.gameObject);
}
My console throws a ton of errors even though I have implemented the null check I've seen in other responses. The "KillPlayer" function should only be run once and even if it isn't it still shouldn't have the issue because the program is checking if it is null. What am I doing wrong?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613020330im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to delete objects of a parent and then instantiate a new one? 1 Answer
"the object of type transform has been destroyed but you are still trying to access it" problem, 1 Answer
How to detect a single collision when 2 identical gameobjects collide. 1 Answer
Unexpected symbol 'Instantiate' [SOLVED] 1 Answer
How can I destroy many instantiated objects on endless game 1 Answer