How Can I assign a gameobject via script?
Hello! Sorry, I can't understand ....
I have a "Player" in my hierarchy and a child object of this "Player". Ehm, don't mind about names please! ;-)
So I have
Player I-> FartPoint (and here there is a script)
Now I am instantiating enemies but when I made a "PreFab" of this enemy ... prefab loses references to that "FartPoint" (and to the attached script I need), so I have to assign It via script when created
I tried different solution in start
myPlayer = GameObject.FindWithTag("Player"); or fartPoint = GameObject.Find("/Player/FartPoint");
but nothing worked! I always get "UnassignedReferenceException: The variable fartPoint of Enemy has not been assigned."
What do you suggest me to do?
Thanks!
Your answer
Follow this Question
Related Questions
setting a variable to a GameObject that has a certain RGB value??? please help 0 Answers
GameObject.Find throws be a error when trying to find a child. 1 Answer
(Solved) Findout if an object exist in the scene, but dont trow exception 1 Answer
Why does GameObject.Find() work in ones and not in others? 1 Answer
Trouble finding GameObject in a script that is on an Empty brought over from previous scene 0 Answers