FPS crouching

How does this work with the player box, they player box is the size of the player.
At the moment i have got the keyboard logic and animation of the player crouching.
When i crouch under something the playerbox obstructs it.

Scale down the ‘playerbox’ so you can ‘fit’ under things.

Did that. However i don`t need to crouch to go under things i walk straight through.

Here is a .blend to show what i`m stressing.
http://www.pasteall.org/blend/24228

When you press crouch you could replace the hitbox mesh to be smaller than the normal one to match “crouching” height, then when you stand up replace it back to bigger hitbox mesh again?

That’s not a good idea. When the player crouches under something and releases crouch still under it the full sized player box would appear inside the geometry and cause unexpected results. Also scaling the player collider will scale whatever you have parented to it ie models and also move empties, camera, lights if they aren’t situated at the exact object center.

The best setup that I know for crouching is to make your player collider the size of crouched character and parent another collider to it that moves up when the player is not crouching. When you put them in different collision groups they can go freely inside each other. That still needs a raycast or something to check whether the player is able to stand fully up or if there is something blocking a bit of the way if you want definite 2 states (standing and crouching) and nothing in between them.

Well it would require python but you could make a check if there’s enough room above the player to “release” from crouch even if the player is not pressing crouch.

So as long as player is either pressing crouch button or character has no room above enough, character would remain in crouch position.
Only if there’s enough room above, crouch would be released and mesh would be replaced.

EDIT: Actually you could just shoot a ray with a sensor and build a check with logic bricks.

Replacing meshes is not what i`m trying do.
There has to be a simple way to do this.

EDIT:
Is there anyway to add another collision box
on to the main one ?
So when i crouch, the head collision box goes
down with it.

The answer is quite simple really make the collision box for the character only at the bottom of the character.

I animated the player collision box with scaling and it worked: link
The only problem is since the main character collision box is scaled the hand and gun get a lil squashed but if you were to add in a crawling animation while crouched that should cover it up :smiley:
hope this helps
Also you could add multiple collision boxes, one for feet, one for upperbody, then just animate the upperbody collision falling into crouch position

@3dsolarsystembuilder That won’t stop the player’s top half from walking through the wall

Yes but when you through a hole in the wall, the top end of the wall
wont be detected since the collision box is only at the bottom :wink:

Hey dude cheers for checking it out.
Yeah it squashes it, so i can`t use this method.
If only there was a way it would not scale the child.

But he could make the character automatically crouch when he gets under something by using radar that detects a property that triggers the crouch animation.Sorry my mistake i did not read the whole thing.

O.o

Did you read my post?

I did.
However i don`t know how to make collision groups.
Maybe you can tweak the .blend

you can implement this setup on a fps:

Attachments

crouch.blend (499 KB)

Amazing, i got this too work however i`m having a problem.
Like you can see in the blend, the charater seems to bounce up and down?
any way to resolve this ?

you did scaled the player object out of the edit mode

select the player object and press ctrl+A, next, select ‘scale’

the object will have the scale parameter corrected :wink:

Thank you very much, i will credit you :slight_smile:

EDIT:
There a problem when giving a crouch animation.
The crouch stands back up when going under ?

here:

http://www.pasteall.org/blend/24249

I think this setup became a little complex now, be careful, it’s like a house of cards ^^’