Files
BoostBaller/Assets/Scripts/Goal.cs

39 lines
826 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Goal : MonoBehaviour
{
public GameManager gm;
public int playerNumber = 0;
// Start is called before the first frame update
void Start()
{
this.gm = GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>();
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter(Collider other)
{
if (other.transform.tag == "Ball")
{
if (this.playerNumber == 1)
{
this.gm.scorePlayer2 += 1;
}
if (this.playerNumber == 2)
{
this.gm.scorePlayer1 += 1;
}
this.gm.ResetPositions();
}
}
}