Import existing Unity project
This commit is contained in:
38
Assets/Scripts/Goal.cs
Normal file
38
Assets/Scripts/Goal.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user