- Home /
set SmoothFollow target at runtime via static var
Hi,
I have a textfield in my GUI where i enter a custom name. When I instantiate my player object i change it's name to that custom name using a static var. When I debug I see it's changed, so my static var works. When i try to use that same static in my SmoothFollow script, I get this error : Assets/Standard Assets/Camera Scripts/SmoothFollow.js(9,11): BCE0005: Unknown identifier: 'ConnectionGUI'.
Anyone got an idea ? Thanks.
Eddy.
Answer by appels · May 29, 2010 at 02:18 AM
Thanks everyone. I got it to work. I'm able to assign my prefab at runtime like this :
prefab = Instantiate(Resources.LoadAssetAtPath("Assets/playerPrefab.prefab", GameObject));
and attached the SmoothFollow by finding the gameobject and use it's transform. The transform is what got me confused but all sorted now.
Eddy.
Answer by spinaljack · May 28, 2010 at 11:36 AM
If I understand you correctly you're going about it the wrong way. You need to find the game object with GameObject.Find or better, GameObject.FindWithTag to get the instance of the object and then you can reference it's transform for the smooth follow script.
Your answer
Follow this Question
Related Questions
Camera Target Switch By Tag HELP! 1 Answer
getting static vars from other scenes? 2 Answers
Spawning objects on trigger does not work as expected 2 Answers
Problem with static variables 1 Answer