Whenever I instantiate my main player object from a prefab to the scene, all the GUIs attached to the scripts which are applied to the player don’t seem to work. I had the idea of applying all the scripts to another GameObject in the scene, then instantiating the player within the GameObject. How would I do this? and is there an easier solution? Im using C# thanks
1 Answer
1Solved it with the following code:
public GameObject trike;
public GameObject trike2;
public GameObject test;
GameObject obj;
void Start() {
obj = (GameObject) Instantiate(trike, test.transform.position, test.transform.rotation);
obj.transform.parent = test.transform;
obj = (GameObject) Instantiate(trike2, test.transform.position, test.transform.rotation);
obj.transform.parent = test.transform;
}
}
You should post your code
– DaveApublic class instantiate : MonoBehaviour { public Transform trike; void Start() { Instantiate(trike); } } Then I attached my player from the prefab in the little space in the inspector
– a1exi8Not that it should matter? But try public GameObject trike; and see how that works
– DaveAyeah tried it, doesnt seem to change anything
– a1exi8