I want my character to return to standing position without any glitches even while being pushed. But I can’t figure out how to solve this. Can someone help me fix this?
99% of the code shown is useless.
You are using the character.
The character handles things.
No need to line trace, or update a component. Which causes issues.
The movemenet compont is the one responsible for movement. You have several settings on it that allow you to define how it reacts.
If the intention is to duck when you hit a wall.
First of all, you need to trigger the crouched statate for the capsule to shrink.
Sexond, you can detect collision off the capsule component.
Because it automatically uses sweep, it should allow you to untoggle the crouch once its not being pushed around.
Probably add a check that velocity is 0 - whichay have to be a location value in world space check over 2 or 3 frames.
I don’t think being pushed by objects alters your velocity…
Everything @MostHost_LA said…
Also the pop up is caused by the capsule being lifted off the ground. Once in air
CMC goes into a falling state. This cancels crouch.
Drop a print to string on On Event Landed
.
For something as simple as 2d movement, really you should write your own movement component.
The character is 90% or even 99% filled with useless things - like is in air.
(But way more, it also includes network stuff For replication you’d probably never use).
It reacts way different than you want because its capsule based.
If you went with a box/square collision you wouldnt have lift issues (based on the object sweeping you around).
You can do this in blueprint with a pawn.
You miss out on gravity/would need to implement your own version of it.
But what if it is being pushed around? The entire point of this question is how to untoggle the crouching position smoothly while the character is being pushed.
Wait a doggone minute. I fixed it! In the “Restore Collision Shape” macro, I checked “Sweep” in the “Set Actor Location” node and the problem’s gone!