38 lines
1 KiB
C#
38 lines
1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class PlayerSwitcher : MonoBehaviour
|
|
{
|
|
[SerializeField] private Player player1;
|
|
[SerializeField] private AutomatedPlayer player1AI;
|
|
[SerializeField] private Player player2;
|
|
[SerializeField] private AutomatedPlayer player2AI;
|
|
|
|
private void Update()
|
|
{
|
|
if(Input.GetKeyDown(KeyCode.E))
|
|
{
|
|
SwitchPlayers();
|
|
}
|
|
}
|
|
|
|
public void SwitchPlayers() //i bet if i made it a parameter i wouldn't have to make an if statement. but it's literally 5 am and i'm lazy
|
|
{
|
|
if (player1.enabled)
|
|
{
|
|
player1AI.enabled = true;
|
|
player1.enabled = false;
|
|
player2.enabled = true;
|
|
player2AI.enabled = false;
|
|
(player2.transform.position, player1AI.transform.position) = (player1AI.transform.position, player2.transform.position);
|
|
}
|
|
else
|
|
{
|
|
player2AI.enabled = true;
|
|
player2.enabled = false;
|
|
player1.enabled = true;
|
|
player1AI.enabled = false;
|
|
(player1.transform.position, player2AI.transform.position) = (player2AI.transform.position, player1.transform.position);
|
|
}
|
|
}
|
|
}
|