N1ckGreek N1ckGreek - 1 month ago 5
C# Question

How to assign Transform via code

How can i assign automatically the Transform via code using something like

GameObject.FindObjectOfType
?

enter image description here

Answer
raycastEnd = GameObject.Find("RaycastEnd").transform;

If you have multiple objects named "RaycastEnd" it will return the first one. the first one may be unpredictable.

Comments