I’m looking for some documentation on collision, but can only find it within a class. I’d prefer not to do that as it is just a CreatePrimitive(); Provided example code from Unity Documentation below.
using UnityEngine;
using System.Collections;
public class DestroyCubes : MonoBehaviour
{
void OnCollisionEnter (Collision col)
{
if(col.gameObject.name == "prop_powerCube")
{
Destroy(col.gameObject);
}
}
}
Anything on how to get collisions of a specific GameObject. In my case,
To detect collision you need following thing attach to gameObject where you want to detect collision.
rigidbody component attach to it.
collider component attach to it.
Script which detects collision. Script have method OnCollisionEnter (to detect collision) and if your collider component have IsTrigger Set than use OnTriggerEnter .
OnCollisionEnter function called when your gameObject Collide to other gameObject.
Other GameObject must have Collider attached to it.