Hello,
Wondering if collider is transform or gameObject?
Why should I destroy collider like this:
Destroy(collider.transform.gameObject);
Instead of this:
Destroy(collider.gameObject);
Hello,
Wondering if collider is transform or gameObject?
Why should I destroy collider like this:
Destroy(collider.transform.gameObject);
Instead of this:
Destroy(collider.gameObject);
They’re just different references to the same gameobject
It means that, both of them will be worked exactly the same?
Yes, they both reference the same GameObject.
Colliders and Transforms both have a reference to their GameObjects, which is why you have multiple ways to reference the GameObject here.
If you just need to reference the GameObject and don’t need to do anything with its Transform, just use collider.gameObject
.