ACharacter::Crouch does not have a smoothing option. Everyone is rolling their own crouching implementation because of this small deficit.
The editor is designed to work with the ACharacter method. I can’t set ‘crouch walk speed’ in the editor, for example, for this reason. Makes our implementations feel jimmy-rigged. Nevermind that the rest of the engine altogether is designed to interact with the official ACharacter::Crouch.
You’ve designed an otherwise robust system for crouching that we can’t use because of this one deficit. Please give us something to smooth the crouch.
We send you a warm welcome to the Unreal Engine community!
Just so you’re aware, this topic has been moved from the Development - Programming & Scripting forum category to the General - Feedback & Requests forum category.
Technically, your post was not in the incorrect forum, but since your post is considered feedback for improving the engine, the Feedback & Requests forum is the best place for Epic staff visibility regarding improvements.
Thank you so much for your feedback and Happy Holidays!
Why does this matter to you? The animation it plays when switching states can still be smooth.
If you really need to animate the height of the capsule over time, you could subclass the ACharacter class and maybe UCharacterMovementComponent, which means that you can still use the editor support for crouching, but have your custom behavior.
The animation it plays when switching states can still be smooth.
I don’t see how to do this in a graceful way. Maybe you’re thinking of third-person, I’m thinking of first person.
And yeah it would be the UCharacterMovementComponent but the crouching behavior defined there is massive and interacts with other functionality so I’d have to tie up a thousand loose ends there and try not to break anything else.
It seems reasonable to have smooth as opposed to snapping first-person crouching available without untold hacking.
Oh, the challenge is the camera animation in first person when going into/out of crouch? The best I can think of is temporarily taking over the camera location/control when entering into/out of crouch. You can probably do this with a timeline and a separate temporary camera actor or something. Which seems a bit annoying, but better than subclassing everything!
There’s at least three ways (probably more) to take over the camera; override the base “where is the camera?” functionality (APlayerCameraManager in C++); override the “which actor has the camera?” functionality (Set View Target With Blend in Blueprint) or move the curently-active camera component/actor.
The character movement interacts with so many things, because it has to work well on a network, and not get “stuck” on terrain, and solve for a bunch of other annoying gameplay problems that come up in fast-paced FPS games. It’s really hard to do that in a fully modular way, because, as you say, everything just ends up depending on everything if you really want the player feel to be first class and robust…
Yes that makes sense as to why the crouch functionality is not as easily editable in a nice modular way as we might like.
My solution was pretty much what you suggest. There is still a problem though.
The engine detects whether or not the Character is crouching (ACharacter::bIsCrouched). If I move the camera and etc to simulate crouching, then bIsCrouched = false. I’m crouching, but the engine doesn’t recognize that so I lose out on that robust and well considered protective functionality that you mention. If I set bIsCrouched = true, I’m protected but then I have a silly battle of my code vs engine code where the engine definitions take over again. I can’t have smooth crouching and all those excellent features that you mention at the same time.
I think the best place to fix it or give a smoothing option is in the engine code. Default crouch’s roots are too deep in the codebase, we can’t fight it. I think this is worth looking into because probably every first person game made with UE has had to hack this up. I’d make a pull request but I don’t think I’m good enough. Hopefully someone professional has time.
My suggestion is to still use regular crouching, but when you send the crouch signal, also take over the camera. Then give up the camera once you see the character is not-crouching, and you animate back to full height.
That way, simulation works well, and the camera still moves smoothly.
Presumably you don’t actually need the capsule to change size smoothly.
There are a few ways to get there; for example, you can play a timeline that lerps to the crouched camera position, and once you’re there, you give up camera control immediately (so it’s back with the controller for an extended crouch.) And, similarly, when crouching goes off; animate lerping to the raised position, and then give up camera control again.