Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved How to make Character Controller NOT collide with things

Discussion in 'Scripting' started by MinhocaNice, Feb 16, 2021.

  1. MinhocaNice

    MinhocaNice

    Joined:
    May 3, 2020
    Posts:
    249
    I am developing a simple FPS game using C# and I plan on making it multiplayer, and although the game is PvE I want to add a toggle to make Friendly Fire possible. However, the Character Controller Capsule blocks raycasts before the actual hurt box of the player is hit. I tried using IgnoreRaycast layer, but it didn't work (and I can't anyway because I already have a "Player" layer for other purposes).

    It also collides with things like items on the floor, and since I have a boolean to check if it's grounded, sitting on top of an item for a while then falling down even 10 cm make the player take huge fall damage (I was able to fix this by going to Edit > Project Settings > Physics and making the two layers not collide).

    Is there a way to make so Character Controller collides ONLY with the ground? Or better, make it collide with nothing at all and use another collider inside a child object to check for every collision?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,932
    CharacterController is a collider, so it behaves the same way as other colliders in Unity.
    As you have explored - the way to do this is by using the layer settings in Physics.
    If you want this - why use a CharacterController at all?
     
  3. brain2frog

    brain2frog

    Joined:
    Feb 16, 2021
    Posts:
    4
    upload_2021-2-16_17-52-59.png
    i dont really know but try to disable the the box collider of your pysics obstacles . . . set true with this trigger if you want to check the hit of an object . .. disable the trigger of your capsule or fps controller . . or better try to keep to place the raycast a bit more in front of your char . . it seems like the start position has been placed in your controller capsule
     

    Attached Files:

  4. MinhocaNice

    MinhocaNice

    Joined:
    May 3, 2020
    Posts:
    249
    Like the name suggests, to simply control the character's motion.
     
  5. MinhocaNice

    MinhocaNice

    Joined:
    May 3, 2020
    Posts:
    249
    There are other objects that I want to be able to collide with eachtother, including box colliders I added to the player object itself. The only one I don't want to collide with others is the character controller.
     
  6. Avisan

    Avisan

    Joined:
    Apr 4, 2021
    Posts:
    2
    The only thing I can think of is making the controller geometry as small as possible