onCollisionEnter vs onTriggerEnter

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?

From my understanding Translate means that it’ll ignore collisions. That is your problem. To give you an example if you Translated your character down he would go through the floor. So

function FixedUpdate()
{
 rigidbody.velocity = Vector2(0, speed, 0);
}

If it has a rigidbody you should put it in FixedUpdate. You don’t need to multiply by Time.deltaTime because it runs at the same time step as FixedUpdate. However, when working with rigidbodies usually you want realistic physics and manipulating the velocity directly like I just did will lead to unrealistic physics. It will work exactly like translate did though and if you were happy with that then this will work for you. If any part of my answer confused you (maybe some of the terms) let me know in a comment and I will explain it.