First person crouching

Hello I need help making first person crouching for a game that can be toggled on and off but also makes the player slow down (preferably subtracting speed) With this I need help so the hitbox changes so the player can go under objects.

You could do this, just make a boolean variable called isCrouching or something

if key c is pressed: (trigger once)
    toggle variable isCrouching

if variable isCrouching is true:
       set y-scale of player to .7

if variable isCrouching is false:
       set y-scale of player to 1
       
# for the speed

if variable isCrouching is true, (keys you use to move) pressed:
       move the player at a slow speed

if variable isCrouching is false, (keys you use to move) pressed:
       move the player at a faster speed

These are conditions you can use, just in word form. Is it a multiplayer game? Because this is a fix that you can’t see because its first person, but others can. If you want it even smoother, use tweens. Its a behavior you can add to an object. If you will use tweens, just change the y-scale actions to tween y-scale of player to .7 using easeInOutQuad as "crouch"
Oh! I’m sorry. I forgot to mention speed. I have fixed it.

thank you there had to be tweaking of the code but thanks for the base code!

1 Like