gameObject.transform

Hello,
so I wrote a code yesterday. And today I can’t find out how did i made my algorithm work. There is one line in my code which confused me… it is 4 a.m. right now and i still don’t know what does that mean. Can you help me please?

if (coll.gameObject.transform.position.y + coll.transform.lossyScale.y / 2 < rg.position.y && coll.gameObject.transform)//norm jump
{
        return true;
}

coll.gameObject.transform … (coll is Collide) … it is not boolean, is it? Why does this work :smiley: and, that’s even worse, why is my algorithm aboslutelly messed up if I remove this line?
Thank you.

Well, that part just makes no sense. It either just results in “true” or if “coll” is null it would throw a null reference exception.

The reason why this works is because the base class for most Unity classes UnityEngine.Object has an implicit conversion operator. It returns true if the object “exists” / is still alive and will return false when the object has been destroyed.

Finally this is unnecessary complicated:

coll.gameObject.transform.position.y 

you can just use

coll.transform.position.y 

You actually did this for your lossyScale