- Home /
Question by
the_paladon · Apr 14, 2021 at 05:29 PM ·
gameobjecttransformparent-childreferencingchild-to-gameobject
How do I reference the transform component of a gameObject to a script automatically?
I tried using this in Start() :
patrol1 = GameObject.Find("PatrolPoint2").transform;
patrol2 = GameObject.Find("PatrolPoint2").transform;
It worked but only when I had one instance of an enemy. Now that I have several, they can't differentiate between the Patrol Point of each other and pick the same one. Basically all of the patrolling enemies go to the same patrolling route and follow that.
I cannot solve this problem by GetComponenetInChild() because the gameObject of the enemy and the 2 patrol points are all children of another gameObject.
Comment