Search Unity

Ignoring collisions between spawned CharacterControllers

Discussion in 'Scripting' started by mgeorgoulopoulos, Jul 26, 2011.

  1. mgeorgoulopoulos

    mgeorgoulopoulos

    Joined:
    Aug 24, 2009
    Posts:
    66
    Hello,

    I have several CharacterController NPCs running around my level, which should not collide with each other. I have tried setting the detectCollisions flag to false, however this does not change anything.

    Is there another way to achieve this?

    Many thanks
     
  2. bdev

    bdev

    Joined:
    Jan 4, 2011
    Posts:
    656
    If they are never supposed to collide you should should take a look at Layer Based Collision Detection.

    So you would make a new layer called something like Characters, set all characters or the prefabs to use that layer, and then in the physics settings uncheck the box on the grid Characters x Characters so any object on the Characters layer does not collide with another.
     
  3. mgeorgoulopoulos

    mgeorgoulopoulos

    Joined:
    Aug 24, 2009
    Posts:
    66
    Thanks BDev, this will probably work, I will try it later on, however, what if I want to enable collisions at some point? I cannot find this setting exposed in the script.
     
  4. bdev

    bdev

    Joined:
    Jan 4, 2011
    Posts:
    656