Search Unity

Adjusting Player Collision Volume?

Discussion in 'Scripting' started by Xander-Davis, Jun 4, 2011.

  1. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    Is there a way I can adjust the player collision volume? I didn't see any collider on the First Person Player Controller anywhere... Did I miss something?

    This would be for a crouching action.

    Thanks
     
  2. SkaredCreations

    SkaredCreations

    Joined:
    Sep 29, 2010
    Posts:
    296
    Your collider is the Character Controller component where you can set the radius, height, center, etc
     
  3. Xander-Davis

    Xander-Davis

    Joined:
    Apr 23, 2011
    Posts:
    441
    How could I manipulate the Character Controller height upon pressing a Crouch button (like 'C')? Since the Character Controller isn't a script and there isn't even an option for it in PlayMaker, how would you go about making its height dynamic?
     
  4. cat_ninja

    cat_ninja

    Joined:
    Jul 14, 2010
    Posts:
    197
    To do that you first get the character controller
    controller = gameObject.GetComponent(CharacterController);
    then adjust the height
    if(Input.GetButton("C"))
    controller.height = crouchHeight;
    else
    controller.height = startHeight;
    Just one thing i don't know how to fix this but you need your position to change when you go back up or else your player wil fall through
    the floor you can Lerp the values to make it smoother Good Luck :D