excuse me i’m a little bit confused when using Instantiate() function…
so here’s my code
var playerMale : GameObject;
var playerFemale : GameObject;
var savedplayer : int = 0;
function Awake () {
savedplayer = PlayerPrefs.GetInt("selectedplayer");
playerMale = GameObject.Find("Cube1_M");
playerFemale = GameObject.Find("testchar_F");
if(savedplayer == 1){
Instantiate(playerMale, Vector3(2,2,2), Quaternion.identity);
playerFemale.SetActive(false);
gameObject.AddComponent("PlayerStats");
}
else if(savedplayer == 2){
Instantiate(playerFemale, Vector3(0,0,0), Quaternion.identity);
playerMale.SetActive(false);
//playerFemale.SetActive(true);
gameObject.AddComponent("PlayerStats");
}
}
that was how my character spawnned, but the problem is, the character selection in on different scene, so in THIS scene that contained script above there’s no object, so i confused,
to Instantiate i should decclare the playerMale as an GameObject, but GameObject.Find need the object itself… is there any way out from this?
Thanks before.
yeah, i mean, when player choose character, we store the data right? it was the information that determine whether the player will be a, b, or c, how do i connect that to the instantiate that object? and also if i add it on inspector it wont show up on scene right?
– Rgalaxy