Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to do selective collisions

Discussion in 'Scripting' started by robertseadog, Nov 30, 2005.

  1. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    Im wondering how to make some rigidbodies bounce off a wall, while others simply go right through it ( don't collide), but I don't get it. I guess I could check if the other is a certain model and then apply a and remove a mesh collider to the wall in real time, but wouldn't that become processor intensive?

    Also: Is it just me or is the mesh collider more stabile than the box?
     
  2. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    what Im trying right now is this but it doesn't work :

    Code (csharp):
    1.  
    2. function OnCollisionEnter (object : Collision) {
    3.     if (object.other.gameObject.CompareTag ("cubez")) {
    4.     object.other.rigidbody.isKinematic = true;
    5.     object.other.transform.position.z += 50;
    6.     Destroy (object.other.gameObject);
    7.     }
    8. }
    9.  
     
  3. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    actually I forgot to assign the script again! :eek:
     
  4. guategeek_legacy

    guategeek_legacy

    Joined:
    Jun 22, 2005
    Posts:
    659
    The Joy of being Human :)