Hi guys
im trying instantiate my player but i got an error this is a bit of my code
//class PlayerCreateMenu
InstantiatePlayerSelected instantiateplayer = new InstantiatePlayerSelected();
void OnGUI()
{
ButtonCreation();
}
void ButtonCreation()
{
if(GUI.Button(new Rect(350,500,50,20),“Create”))
{
instantiateplayer.InstantiateMaleHuman();
}
}
//end class
this is my player selection menu and when i change scene i want destroy dis but i need instantiate mi player in this scene and save it for next scene. here is my instantiate class
//class instantiatePlayerSelected
public Transform Male_Human;
public void InstantiateMaleHuman()
{
Instantiate(Male_Human, transform.position, transform.rotation);
}
//end class
i had attached this script on a new gameobject but i got this error when i click button create
NullReferenceException
UnityEngine.Component.get_transform () (at C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/ExportGenerated/Editor/UnityEngineComponent.cs:21)
InstantiatePlayerSelected.InstantiateMaleHuman () (at Assets/Scripts/InstantiatePlayerSelected.cs:19)
PlayerCreateMenu.ButtonCreation () (at Assets/Scripts/PlayerCreateMenu.cs:429)
PlayerCreateMenu.OnGUI () (at Assets/Scripts/PlayerCreateMenu.cs:97)
i hope some can help me plz.