and i have another script that is alwais active whic has all the references and most of game logic for that scene but for them to work i need the player and a child game object that is in the player and i was try’ing this
public GameObject player ;
public GameObject guns; // Guns are the players children
void Start ()
{
player = GameObject.Find ("Player");
guns = transform.Find ("Guns").gameObject;
}
but i think the scene managers code starts first and it cand find fast enough in start fucntion so how can i find the player and gun’s in update and then disable that finding fuction ? because i read that if gameobject.find is runing in update it gives bad performence
GameObject.Find is generally bad no matter what(Update is not a good idea). What would be better is when you create the player, you assign that player to the proper variable instead of having to go find it later.
If your player “dies” you don’t have to instantiate again. Just reset the player. Or, when you do a new instantiate, you reassign the new player object.