I’m trying to build a pool game where the pot has a collider. Now on collision with a ball, I expect that particular ball that collided to disable.
The code below is what I’ve tried but it only allows me to set the ball manually. How do I automat and detect the right ball directly?
using UnityEngine;
using System.Collections;
public class pot: MonoBehaviour
{
//allows me to set collider
public SphereCollider ball;
void OnTriggerEnter(Collider other) {
Debug.Log("Ball potted");
ball = GetComponent<SphereCollider>();
ball.enabled = !ball.enabled;
}
}