- Home /
Assign variable to non existing transform
Hello, I have found a script witch makes it possible to enter and exit a car. For the script to work you need to assign a number of variables: vehicle, player, exitPoint, doorTriggerLeft, carCamera and playerCamera. The problem is that I spawn the player from a prefab if he joins a server (it is a multiplayer game) or if he starts a server. But I can't assign a transform that is not yet in the scene to a variable. I have tried to make a Global that is true if the player spawns and as soon as the player comes into the scene I set the player variable to the player transform like so
if(PlayerCamera.GetComponent("MPBase").ingameGlobal == true)
player = transform.Find("test22 (clone)");
but that doesn't seem to do anything. MPBase is my multiplayer script, ingameGlobal is the variable that sais wheter there is a player ingame or not and test22 (clone) is the name of the transform after initialising.
Does anyone have an idea about how to het this working I would greatly appreciate help.
(if you think my English is bad you're right, i'm dutch and stil in school)
Your answer

Follow this Question
Related Questions
global variable doesn't work 2 Answers
Unable to modify a variable in another script 2 Answers
How to use same code at multiple scenes ? 1 Answer
Increase Static Var gradually 1 Answer
How to make a var "global" 0 Answers