Hey guys I need help for a score broad system for my school project. My problem is that I have c sharp coding on my ball and once you score the ball the ball will teleport to its original ball position , and that’s great, but it will also give both players a point and that’s where i’m struggling to fix if you can lend me a hand that would be great.
using UnityEngine;
using System.Collections;
public class BallManager : MonoBehaviour
{
public int Score1;
public int Score2;
public void OnTriggerEnter(Collider other)
{
// if (other.gameObject.tag -- "Goal1")
{
transform.position = GameObject.Find("BallPosition").transform.position;
// this.gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;
Score1 += 1;
}
// if (other.gameObject.tag-- "Goal2")
{
transform.position = GameObject.Find("BallPosition").transform.position;
// this.gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;
Score2 += 1;
}
}
public void Update()
{
GameObject.Find("Score1").GetComponent<TextMesh>().text = Score1 + "";
GameObject.Find("Score2").GetComponent<TextMesh>().text = Score2 + "";
}
}