I need to be able to get an array of all colliders that are thuching the collider of witch the script is a component.My collider is set to triger ,if that is inportent
thanks in advance , sorry for bad spelling , all scripts in c# please.
I need to be able to get an array of all colliders that are thuching the collider of witch the script is a component.My collider is set to triger ,if that is inportent
thanks in advance , sorry for bad spelling , all scripts in c# please.
Something like this perhaps?
public List<GameObject> TouchingObjects;
void Start() {
TouchingObjects = new List<GameObject>();
}
void OnTriggerEnter(Collider collision) {
if (!TouchingObjects.Contains(collision.gameObject))
TouchingObjects.Add(collision.gameObject);
}
void OnTriggerExit(Collider collision) {
if (TouchingObjects.Contains(collision.gameObject))
TouchingObjects.Remove(collision.gameObject);
}
You might have to add using System.Linq;