How to check the position of the game object
I want to check if two gameobject's X are the same then call a animation
But I don't know how to use transform.position on a gameobject
Can someone help me?
Answer by metalted · Feb 27, 2017 at 11:24 PM
You can access the transform of a gameobject by typing gameobject.transform.
A little example i like to use is OnTriggerEnter(Collider other); it runs code whrn a collider enters a trigger.
The gameobject that entered is other.gameobject. The transform that entered is other.gameobject.transform. The x position of the collider could be other.gameobject.transform.position.x.
Answer by deserdoo · Nov 22, 2019 at 01:40 AM
private Transform transform = GetComponent<Transform>();
private Vector3 position = transform.position;
Your answer

Follow this Question
Related Questions
Moving an array of Vector3 with the GameObject (Path-System) 0 Answers
Disable gameObject in animation 0 Answers
Cube a roll .what can I do for integer output? 0 Answers
A object closer to camera than B object, but A object is behind B and is not visible 1 Answer
Every GameObject that has a rigidbody, won't stay at Z 0 and I don't know why 0 Answers