Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Increase Height of CharacterController Without Jitter?

Discussion in 'Physics' started by vostok4, Jun 3, 2017.

  1. vostok4

    vostok4

    Joined:
    Nov 1, 2015
    Posts:
    73
    Hi, I'm having a problem with crouching in an FPS game.

    I've been adjusting the CharacterController.height in FixedUpdate(), and to crouch the results are OK. On downward motion the camera smoothly falls down as the actual capsule collider is made smaller then quickly floats down.

    However, I have a big problem with increasing the height (standing back up): if I try a 1 frame approach (just height = standingHeight;) then the capsule will intersect with the floor collider, and "jump" out of it, giving me an extremely quick and abrupt (and unusable) standing motion. If I try to lerp the height up to standingHeight, then I get the same behaviour, just with maybe 10 smaller/jerkier steps. I've tried to increase the transform by (0, standingHeight / 2, 0) on the frame of height increase to move up the capsule without snapping through the floor, but that doesn't work.

    Does anyone know a good strategy for implementing crouching? I need to actually shrink my capsule collider because crouched walk lets you get into smaller places.

    Thanks!
     
  2. Firesoft

    Firesoft

    Joined:
    Dec 20, 2016
    Posts:
    308
    Same Problem
     
  3. vostok4

    vostok4

    Joined:
    Nov 1, 2015
    Posts:
    73
    The way I fixed my problem: I have my camera on a child of the FPC / Capsule Collider. I set a box collider trigger for "lower areas", and in that area I ease the camera gameobject down to crouching height, and out accordingly.

    I know its stupid, and it sucks, but it was the quick easy way to achieve good visual results. Maybe other games do the same, I'm not sure. Good luck.
     
    Firesoft likes this.
  4. BoonDev

    BoonDev

    Joined:
    Dec 17, 2013
    Posts:
    4
    You need to adjust CharacterController.center as well when you adjust height (set it to half height + any foot offset you might be using)
     
  5. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    4
    Same problem here. I just try to update "center" of CharacterController but nothing changed.