Question by
Feydrich · Oct 07, 2020 at 06:49 PM ·
bugif-statementsmissing-reference
Mising(GameObject) not firing in if statement
Unity 2D - topdown I have a shadow prefab and a controller script that makes the shadow follow spawned enemies and objects. It works but the issue is once I destroy the attached enemy the shadow stays on the ground.
I wanted to destroy the shadow if the target entitiy gets destroyed but for some reason the if(target == null) isn't triggering.
this is my test code in the logwarning just to see if it works (it don't)
if (target == null) {
Debug.LogWarning("object missing");
}
Comment
the shadow prefab is just a sprite with a script to follow anything set by the public target