I wanted to add a new custom crouched half height when the character is prone. I can’t change the values dynamically. I can’t use the Set Capsule half height since that mean there will not be ground collision and char will sink. Any ideas?
You are not missing anything. This is something I was struggling with for a minute, but unfortunately it is a serious oversight on epic’s part, somebody did not expose this variable to be set by blueprints (intentionally or unintentionally I do not know). I did put in a request to have it exposed, hopefully one day it is.
Thanks.I hope they fix it soon. It will make my life a lot easier if i can change capsule size from the ground.
In the meantime you can create your own blueprint node by adding a C++ class. Have it take a CharacterPawn and a float as input params, and that should do the trick.
Hi! Could you point me towards a tutorial or something on how to achieve this? Or can you be more explicit?
Best regards,
Alex
I found this tutorial on how to expose split screen on/off to blueprints. You could use the same approach but for the set capsule half height on player character class as a parameter to a function library function like this one:
awesome! Thank you!
This is how you change the capsule half height, but not the crouched half height, as OP wanted.
It’s the same capsule.
Capsule half-height is different. If you change the value, it’s going to shrink from the center of the character, not from the floor - try it while looking at the viewport. The Crouch Half-height sets the crouching height when using the Crouch and UnCrouch functions and shrinks to the floor. Also due to the fact that it shrinks from the center, your character will fall into the floor when you change it. It’s got a very limited use case; adjusting the player capsule while swimming might work, but certainly not for crouching.
Nice, thank you for making this clear! but another problem emerges on my end (FPS with charactermesh)
to avoid a quick snapping on cameraview while crouch/uncrouch, i put some springarm component on camera, and set camera lag to true. It’s now having smooth transition on Z direction.
But when my character tries to move forward, my camera lags behind the character, so it’s kinda paradox, any ideas?
Actually, yes. I just created a system to deal with this in my own project. What I did was I attached the camera to the player mesh instead of the capsule so that when you adjust the height of the capsule it doesn’t affect the camera. Then I created a Timeline to smoothly adjust the height of the camera between a standing and crouched height variable. Then when you crouch/uncrouch, you also play the timeline to blend the camera.
You can copy and paste my nodes from here:
Just realized there’re a lot of extra nodes that are specific to my character. The Body Location and Bot Location stuff is obviously not necessary for you. The Hide Head is just me hiding the neck bone to make the character’s head mesh disappears when crouching because it was clipping into the camera. Obviously, you would need to adjust to suit your needs.