void Setup() { if(!isInitialized) { Player[] players = GameObject.FindObjectsOfType<Player>(); if(players.Length == 2) { playerA = players[0]; playerB = players[1]; isInitialized = true; } // else // { // throw new System.Exception("there must be exactly two players in the scene!"); // } } }
public void MeleeAttack(Player enemy) { GetComponent<Rigidbody>().AddForce(transform.forward * 200, ForceMode.Acceleration); if(enemy != null) { enemy.OnGetHit(transform.position + Vector3.up); } }
void Awake() { m_Character = GetComponent<PlayerController>(); m_Player = GetComponent<Player>(); }
public static Player GetOpponent(Player player) { return player == instance.playerA ? instance.playerB : instance.playerA; }