|
Hi! I know that i can have two object not to collide by using physics.ignorecollision. But what i would like to do is have many objects of a same class not to collide between each other... isn't there a way to make a collision group so this objects don't collide? If it is not posible how can i call physics.ignorecollision for all of them in an efficient fashion? Thanks!
(comments are locked)
|
|
There's currently no built-in way. There's a feature request for this on the Unity Feedback Forum which you could add your vote to: http://feedback.unity3d.com/pages/15792-unity/suggestions/163341-physics-layer-based-ignore-collision In the meantime, you could use this neat collision manager script on the wiki, written by Ryan Scott.
(comments are locked)
|
|
This is kind of the same question as this one, which I think I've answered, although it has actually been asked later than this one ^^.
(comments are locked)
|
|
I used this with Kinematic Rigidbodies (that weren't controlled by physics) and used OnTriggerEnter instead of OnCollisionEnter, but it may work in this case also. If you're looking to make all objects of the same class not collide you could create a new "myClass" tag for them and in the OnCollisionEnter function add:
If you want only some instances of this class ignore and not others, you can change that to:
then add the ignoreCollision variable to the class' script:
To set an instance of the class to be ignored, you can create a function in the class' script:
and then call it upon instantiation in whatever script handles that:
(comments are locked)
|
|
Right now i am doing this: function OnCollisionEnter(collision : Collision) {
} Don't know if that is "efficient" but works... It does? I thought doing that within 'OnCollisionEnter' would be too late - i.e. the collision has already occurred by that point. It would ignore any further collisions, but the first would always register.
Nov 18 '09 at 10:32 PM
duck ♦♦
(comments are locked)
|
