How to add multiple characters to my scene using a character selector?
Hi,
I'm new to Unity and having difficulty with C # programming.
I have a character selector and I would like to have the choice between adding 1 or 2 characters depending on whether I select 1 character or if I select 2 characters. My current code allows me to add only 1 character to my scene.
I used this tutorial for my code: https://www.youtube.com/watch?v=F6cc-ISeIPI&list=LL∈dex=3&t=1207s
Thanks !
That's my PlayerSelection script:
public string name;
public Vector3 newPosition;
void Start()
{
newPosition = transform.position + new Vector3 (0, 0, 0.02f);
}
void OnMouseOver()
{
if(Global.cursor != null){
Global.cursor.transform.position = newPosition;
Global.cursor.GetComponent<Renderer>().enabled = true;
}
}
void OnMouseExit()
{
if(Global.cursor != null){
Global.cursor.GetComponent<Renderer>().enabled = false;
}
}
void OnMouseDown()
{
if(Global.selectedCursor != null){
Global.currentPlayer = name;
Global.selectedCursor.position = newPosition;
Global.selectedCursor.GetComponent<Renderer>().enabled = !Global.selectedCursor.GetComponent<Renderer>().enabled;
}
And that's my PlayerControl script:
public Transform[] playerList;
public Transform currentPlayer;
private Vector3 scaleChange;
void Start()
{
if(Global.currentPlayer != null){
currentPlayer = playerList.Single (d => d.name == Global.currentPlayer);
if(currentPlayer == null) Application.LoadLevel("Selecteur");
InstantiatePlayer();
}else{
Application.LoadLevel("Selecteur");
}
}
void InstantiatePlayer()
{
if(currentPlayer != null){
currentPlayer = Instantiate(currentPlayer, transform.position, currentPlayer.rotation) as Transform;
currentPlayer.parent = transform;
Vector3 newScale = transform.localScale;
newScale *= 5f;
transform.localScale = newScale;
}
}
Your answer

Follow this Question
Related Questions
Character shop 1 Answer
Character jumps out of a ramp instead of sliding down it 0 Answers
is it possible to add animations to furniture? 2 Answers
Hey guys I am getting an error that says " 'Play' is not a member of 'UnityEngine.Component'" 1 Answer
How to add first person animations in a third person character? 0 Answers