Download

Crouch Won't Update Until Moved? [VIDEO]

Hey people. I am in need of help once again. The problem has to do with collisions I believe. We’ve created a custom system for crouching, which uses lerp and a timeline to make the animation smooth. It works perfectly, but once the character crouches, he won’t un-crouch until he moves. I did some testing, and it has to do with the height of the character. If I set the half-height to 50 or so, it works well - not stuck once crouched. If I set it to anything lower than that, however, (video uses 21, and I need it at that amount) the capsule’s collision gets stuck inside the floor… I do not know how to fix this… Increasing the amount isn’t an option too.

Crouch Set-up :

Video :
https://youtube.com/watch?v=TYy7tG4O5zk

Problem i think is that, when you decrease your capsule height, you falling to ground. Then when you increase capsule height, your capsule is most probably stucked under the floor so its updated only when you move because then capsule make check where it is and adjust its location… probably if you set height to 1 and then to 50 or whatever you fal under the floor… use third person camera and make capsule visible in your game and check its behavior

I kind of knew why that’s happening, but I do not know how to fix it.

there are more ways… so imo easiest:
create 2 cameras and use “set view target with blend” between cameras and use in-engine built crouch behavior, im not sure how crouch working because i never used it but it must work somehow.

I’d like to try avoiding two cameras, since the problem isn’t in the camera. It’s in the character’s capsule.

Then use only 1 camera and node “move component to” when crouching… im not sure how it is with camera movement when its attached but there must be way.

The problem has nothing to do with the camera though… It is that the capsule gets stuck in the floor - how will moving the camera up fix it? I don’t want to mask the problem, I want to fix it. Also, if you don’t crouch fully and release at the start of the crouch, the character will stand up normally - if that happens, the ‘move component’ will still do it’s thing, and the camera will go way above the character, so it isn’t a fix.

PS I get what you mean now, but that still cannot work. I have a vent in my game, for which the capsule height must be set to really low. This is so the character can go through it.

Truly this was a challenge, it took me almost 1 hours, i did more tests but all had some “bugs” so i found this simple and effective. you can adjust numbers how you want but i think i got nice results with this:

https://youtube.com/watch?v=cFJB0SMh47Q

Hey man. Like I’ve said above, I need the capsule’s half height to be affected by the crouching, and I do not see you setting the half height anywhere in your video. It’s a nice smooth transition, but the capsule remains the same height in your video, and I need it lowered.

… just check BP, im using crouch node, it automatically set your capsule half height to whatever you set… in my test i set it to 20, you can set it to 1 …

Hey Name368,
Thanks for the blueprint. I also need to set my capsule radius to something like 20 too, right? I think the half height cannot be less than the radius.

Yes, that you must do manually, so first you change radius and then crouch half height

Alright, will give it a go today. Thanks.

Another problem - I have two kinds of movement speed for the character. There is a choice, and if the player chooses the wrong thing, their movement speed is lowered for the rest of the game. The problem is, that the ‘crouch’ node has a set speed, and I need two versions of it. How to achieve that?

Hey Name368. Thanks a ton for your help! I decided to try googling something else this time - how to fix the camera’s location rather than the capsule’s half height, and I found what I was looking for! You gave me the right direction to look at :wink:
For anyone else that’s wondering, the solution by Name is correct, but if you need a dynamic movement (not a constant), here’s the guide : How to write a smooth crouching script in blueprint? - UE4 AnswerHub
Instead of ‘set movement to xx’, try ‘get movement -> float * 2 or / 2 -> set movement’. This will let you have a dynamic value for the movement and the crouch will still work wonderfully.