Crouch object detection

I made a crouching system for my FP movement project in unreal and managed to add a sphere trace channel to detect objects above to prevent the player from standing up when obstructed by something above. But once I leave the obstruction I still can’t stand, until I press the crouch button again and release it.


Heres the BP. The events are called from my c++ script to detect if the crouch button has been pressed and released.

How can I get my character to automatically stand up once I leave the obstruction.
(and btw my event tick is already being used for another process, so I don’t think I can use that)

I’m just working on a game where I need exact same behavior, and for me it works fine.

I’m using Paper2D character, though. But I’m quite sure behavior is the same with regular character.

I have a level where player has to crawl through, and when player exists the crawl part, it stands out by himself. There is no need to do any additional logic.

But for this, you must use character that comes with the engine. Are you using it?

If not then approach (in my opinion) would be to do rectangle trace. If trace length is enough, I would allow player to stand up. But I would do this every tick, so that player stands up by himself if crouch is no longer held.

The thing is, I had to make a custom crouch function as the one provided by the engine is just rubbish. Also the race trace and everything works fine, the only issue is I don’t know how to make the check constantly run. And I find it insufficient when using tick as it would be called when it doesn’t even have to, so surely there is another way such as maybe using a set timer function or something? im not sure.

To be honest, even though it’s not way too optimized, I would still use it on tick, but guard it with boolean value IsCrouching. In my racing game, for AI drivers I have like 4 rectangle casts every frame on four cars, during the whole race, and it didn’t eat any of the FPS.

yeah that seems like the best option. I did tht and everything is working fine now. :slight_smile:

Thank you

1 Like

I know this is a bit of an old post, but I found a way around having to use the On Tick method. On the branch you set up after the “Sphere Trace By Channel”, add a Delay function on the true and set it to something small like .1 and then loop it back through the sphere trace by channel.

This way it is only checking for objects above you after releasing the crouch button instead every tick.