I’m finding it difficult to decide which one to use and what triggers such events. I have looked at the API reference for both methods extensively and I’ve done some testing and I’ve got some confusing results.
using UnityEngine;
using System.Collections;
public class PlayerShot : MonoBehaviour
{
public int speed;
void Start ()
{
speed = 15;
}
void Update ()
{
transform.Translate (0, 1 * speed * Time.deltaTime, 0);
}
public void onCollisionEnter()
{
Debug.Log("onCollisionEnter() called");
Destroy(gameObject);
}
}
This is my script that is attached to the “bullet” that gets fired. As I understand it, you only need a rigidbody attached to both objects involved yes? I have a empty game object that is off screen with a box collider attached to it. When the “bullet” passes through the collider it should trigger the method correct? Mine just pass through. Is there something I’m doing wrong here? Or should I be using onTriggerEnter instead?