Projectile collide only with CharacterController

Hello!

I have been trying for a while to create a projectile (GameObject with box collider and RigidBody like the Rocket in the FPS Tutorials) that will only collide with a CharacterController.

I would like to create a ball that bounces off of walls and other basic colliders and explodes when it touches a CharacterController.

Here is my code that I have right now:

// The reference to the explosion prefab
var explosion : GameObject;
var timeOut = 3.0;

// Kill the rocket after a while automatically
function Start () {
	Invoke("Kill", timeOut);
}

//function OnControllerColliderHit (hit :  ControllerColliderHit ) 
//{
//	// Instantiate explosion at the impact point and rotate the explosion
//	// so that the y-axis faces along the surface normal	
//	var rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
//    Instantiate (explosion, hit.point, rotation);
//
//	// And kill our selves
//	Kill ();    
//}


function OnCollisionEnter (collision : Collision) {
	// Instantiate explosion at the impact point and rotate the explosion
	// so that the y-axis faces along the surface normal
	var contact : ContactPoint = collision.contacts[0];
	var rotation = Quaternion.FromToRotation(Vector3.up, contact.normal);
    Instantiate (explosion, contact.point, rotation);

	// And kill our selves
	Kill ();    
}


function Kill () {
	// Stop emitting particles in any children
	var emitter : ParticleEmitter= GetComponentInChildren(ParticleEmitter);
	if (emitter)
		emitter.emit = false;

	// Detach children - We do this to detach the trail rendererer which should be set up to auto destruct
	transform.DetachChildren();
		
	// Destroy the projectile
	Destroy(gameObject);
}


@script RequireComponent (Rigidbody)

I tried using OnControllerColliderHit, but the projectiles still passed through my character.

Thanks in advance for your help![/code]

Is it possible to set that an object will only collide with game objects that have a certain tag or layer?

I finally got it all figured out after I stumbled upon a solution. For your consideration - My projectile script:

// The reference to the explosion prefab
var explosion : GameObject;
var timeOut = 3.0;

// Kill the rocket after a while automatically
function Start () 
{
	Invoke("Kill", timeOut);
}

function OnCollisionEnter (collision : Collision) {
	// Instantiate explosion at the impact point and rotate the explosion
	// so that the y-axis faces along the surface normal
	var contact : ContactPoint = collision.contacts[0];
	
	// Check that we are colliding with the Player
	if (collision.collider.CompareTag ("Player")) 
	{
    	var rotation = Quaternion.FromToRotation(Vector3.up, contact.normal);
        Instantiate (explosion, contact.point, rotation);
    
    	// And kill our selves
    	Kill ();    
	}
}


function Kill () {
	// Stop emitting particles in any children
	var emitter : ParticleEmitter= GetComponentInChildren(ParticleEmitter);
	if (emitter)
		emitter.emit = false;

	// Detach children - We do this to detach the trail rendererer which should be set up to auto destruct
	transform.DetachChildren();
		
	// Destroy the projectile
	Destroy(gameObject);
}

@script RequireComponent (Rigidbody)

This allows me to have projectiles that bounce off walls and only explode on the character. Hope this helps someone who gets stuck with a similar problem.