- Home /
Collider Filtering
Ok, so I have four characters that have to work together to defeat the evil cylinders. There names are Red, Blue, Yellow, and Green. They each have an ability, but they need to work together. Red's is a flamethrower, Blue's is a water gun, Green's is a Cannon, and Yellow's is a shield. Currently, only Green's and Yellow's powers are buggy. I want the other players to enter Yellow's shield, but right now they can't. I need to be able to keep the collider because I need something for the cylinders to interact with. So basically the players need to be able to enter the shield, but not the cylinders.
And with the Green's CannonBalls, the can currently hit other players and Yellow's shield and send them flying off of the level. This is not good. I want the CannonBalls to not do this. Either bounce off the players, or destroy themselves once they hit a player, or just stop their momentum all together. Just stop it from moving the players. Again these need to be able to hit the cylinders. Thanks for helping!
Please remove the spacing from the front of your sentences. It's being read as code and is unreadable currently.
Answer by Invertex · Feb 01, 2014 at 05:04 AM
Use Physics.IgnoreCollision(playerCollider,yellowCollider);
, in the scripts Start() function to have it ignore collision between the colliders.
http://docs.unity3d.com/Documentation/ScriptReference/Physics.IgnoreCollision.html
If you're using the 2D system, you need to have the objects the colliders are on, in different Layers, so that you can use Physics2D.IgnoreLayerCollision(layer,layer); to Ignore their collisions. (though this will supposedly be fixed in the next update where we will get a Physics2D.IgnoreCollision() function.)
Oops, I was describing the method for 2D at first, then thought you were probably not using 2D so I changed it up mid way through, lol. Fixed.
Uhhh, I have tried this.... and no it does not work for me. Here is the script that I used. (it has some other properties on it so just ignore those).
#pragma strict
public var shield : GameObject;
public var redCollider : Collider;
public var yellowCollider : Collider;
public var blueCollider : Collider;
public var greenCollider : Collider;
function Start () {
Physics.IgnoreCollision(redCollider, shield.collider);
Physics.IgnoreCollision(yellowCollider, shield.collider);
Physics.IgnoreCollision(blueCollider, shield.collider);
Physics.IgnoreCollision(greenCollider, shield.collider);
}
function Update () {
shield.SetActive(Input.Get$$anonymous$$ey($$anonymous$$eyCode.N));
}
Just to be clear, you're using regular colliders, not the one's in the 2D section correct?
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Script doesn't find other script 0 Answers
Need some help an object collider that stops a timer then displays it on another scene 1 Answer
TimeScale collider, where all the time outside is frozen? 1 Answer
If Raycast Hits Air 4 Answers