using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerManager : MonoBehaviour
{
public GameObject player1;
public GameObject player2;
private GameObject startPoint;
private GameObject player;
private GameObject startPointss;
private GameObject play;
private int playertast;
// Use this for initialization
void Start()
{
if (playertast == 0)
{
startPoint = GameObject.Find("startPoint");
addplay(player1);
}
else if (playertast == 2)
{
startPointss = GameObject.Find("startPointss");
addpl(player2);
}
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Alpha1))
{
addplay(player1);
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
addpl(player2);
}
}
void addplay(GameObject obj)
{
Destroy(player);
Destroy(play);
player = Instantiate(obj, startPoint.transform.position, Quaternion.identity);
}
void addpl(GameObject obj)
{
Destroy(player);
Destroy(play);
startPointss = GameObject.Find("startPointss");
play = Instantiate(obj, startPointss.transform.position, Quaternion.identity);
}
}