- Home /
physics culling mask?
I want to make my missle not bounce off the player that its shooting from. They're both rigidbodies. How can I do this?
Answer by dhendrix · Apr 10, 2010 at 03:24 AM
By using Physics.IgnoreCollision:
var bullet : GameObject = Instantiate (prefab, transform.position , transform.rotation);
Physics.IgnoreCollision(bullet.collider, gameObject.collider);
Hope that helps! If it does, don't forget to accept as your answer!
Thanks for the response! It works. I'm going to wait a few hours before I accept yours as the right answer in case there's a way to do it using layers. This works for now though!
Well, there is a way using a script. See this question for details:
http://answers.unity3d.com/questions/4167/how-to-make-colliders-to-react-only-with-one-layer
@dhendrix Does the following prevent collision calculations between self?
using UnityEngine;
using System.Collections;
public class Static$$anonymous$$ine : $$anonymous$$onoBehaviour {
void Start() {
Physics.IgnoreCollision(collider, collider);
}
}
There is no such thing as 'collision between self'. An object cannot collide with itself.