Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Weapons scaling fps crouch

Discussion in 'Scripting' started by Bannanaking3, Aug 18, 2023.

  1. Bannanaking3

    Bannanaking3

    Joined:
    Jun 21, 2022
    Posts:
    109
    I have a pretty basic fps character controller that is having a strange issue where when you crouch the weapons squash and stretch with the player's collider.

    this is happening because the parenting of the weapons to the player is
    player collider>camera>weapons

    and when the player collider's size changes to simulate crouching, the weapon objects also change size. is there a way around this? is there a better way of doing this? my reasoning for having the weapons parented to the camera is because the script that switches between them is on the camera, as per the Brackeys tutorial on YouTube about weapon switching.


    I'm considering having the player swap between two different colliders rather than changing the scale of one but I don't know if that will cause issues.

    essentially what I'm asking is if there is a way to scale an object independent of it's children
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Yes, never scale anything but the very tips of your hierarchy.

    This BasicFPCC controller works fine, see for yourself. Parent a cube one level below the top and press crouch.

    If you would prefer something more full-featured here is a super-basic starter prototype FPS based on Character Controller (BasicFPCC):

    https://forum.unity.com/threads/a-basic-first-person-character-controller-for-prototyping.1169491/

    That one has run, walk, jump, slide, crouch... it's crazy-nutty!!