CollisionEnter not firing

I have two objects. One object is in the layer Wall, the other in MovingThroughWalls.

Below is a script I use to move the object through the wall for testing.

using UnityEngine;
using System.Collections;

public class Testmoving : MonoBehaviour {
	
	private Vector3 basePosition;
	private bool moveLeft = true;
	
	public float moveX = 4.0f;
	public float speed = 2.4f;
	
	// Use this for initialization
	void Start () {
		basePosition = transform.position;
	}
	
	// Update is called once per frame
	void FixedUpdate () {
		if (moveLeft) {
			collider.transform.Translate(speed * Time.fixedDeltaTime, 0.0f, 0.0f);
			if (collider.transform.position.x > basePosition.x + moveX)
				moveLeft = false;
		} else {
			collider.transform.Translate(-speed * Time.fixedDeltaTime, 0.0f, 0.0f);
			if (collider.transform.position.x < basePosition.x - moveX)
				moveLeft = true;
		}
	}
}

The Wall has a boxcollider and nothing more and the MovingThroughWalls object also has a boxcollider.

Below is my configuration for the physics.

alt text

For some reason my OnCollisionEnter(Collision collision) (to be clear) on the wall doesn’t fire. I am printing a simple string to see if it works.
Is there something I’m doing wrong here? Any help would be great…

Hi,

How fast is your projectile moving? Physics is calculated at certain step intervals and when travelling fast it can effectively ‘skip’ the object and seem to pass straight through. This script might help you:

http://wiki.unity3d.com/index.php?title=DontGoThroughThings#C.23_-_DontGoThroughThings.js

Hope it helps!

Paul

Apparently one of the two objects needs to have a rigidbody which isn’t kinematic for the collision to fire.