so I’ve been searching for days, found multiple pages but they just didnt have a direct simple answer to this very simple question how do I check if a transform is missing?
i want to make a code like
if(mytransform = missing){
//do stuff
}
if I try to use my transform == null it doesn’t work and its driving me mad right now, it should be so simple right?
anyway thanks in advance.
If you are looking on a game object, there is no need for a check since ALL game objects in Unity come with a Transform. And I do mean ALL game objects. An empty game object is actually just a point in space due to the fact that it has a Transform component.
This, I think, is due to the fact that Transform is used for parenting and you can arent object together so you need a Transform even though the game object is not doing anything rendered in the scene, like a manager.
This only applies for GameObject and not scriptable objects or custom class that are not MonoBehaviour.
if(mytransform = missing)
This above is not checking for nullity or missing, it s trying to assign missing to transform.