Uncrouching under something

I have my own crouch system with a timeline and line trace to check if I can uncrouch etc., but the problem is I can’t for the life of me find a way to uncrouch after coming out from under the object. My crouch is an Action Mapping, and my line trace runs on Tick, which is what causes the problem, I just don’t know what else to do it on.
Here’s screenshots of my Blueprints. At the end of the CrouchLineTrace event, I have the Branch and the Uncrouch Event there forces the player to stay uncrouched because it’s on Event Tick. If that Uncrouch Event wasn’t there, everything would work fine except for coming out from under the object, where it then won’t uncrouch (unless the ctrl key (crouch mapping) hadn’t been released, it would uncrouch like normal if so).


Timeline with interpolation for the capsule and camera.

Crouch Event

Line trace event

Event Tick

Also I’m interpolating the spring arm location because the capsule half height doesn’t move it, so crouching means the camera goes through whatever is above the player. This would be fine if crouching in the air didn’t make the camera visibly move like this (making the player either appear falling very quickly, or rising in the air very slowly, or just staying in the air for a while). Would there be a better way of moving the spring arm without this jarring effect (like Source’s crouch jump and UE4’s default crouch events)?

Thanks,
Spiffy

You want to create three new functions. “Can I Crouch”, “Can I UnCrouch”, “Crouch Trace”.

Press → Can I Crouch → Crouch Event → Set “Is Crouching”.

Release → Can I UnCrouch → UnCrouch Event → set “Is Crouching”

The “Can I Crouch” function will check if falling and anything else you want to prevent crouching. Like swimming etc. Returns a bool you can pipe directly to a branch node.

The “Can I UnCrouch” function will call “Crouch Trace”. Crouch trace will fire a sphere trace the radius of the capsule component. Blocking hit will be the condition. If True, set a timer for 0.1 seconds and call “Crouch Trace” again. On false (no hit) clear timer handle and return a bool (true).

1 Like

Which bool would be returned in the “Crouch Trace” function? Is this the correct setup for the sphere trace so far?

As for the Can I Uncrouch function, I’ve done this:


I’m not fully sure how this all works yet, so elaboration would be great.

Thanks.

I did everything in those screenshots (except for using SphereTraceForObjects as I don’t know how to use that, unless that’s necessary for this) and the player doesn’t stay crouched when under an object lower than their standing height. Is there something I’m missing?

I’m using sphere trace for objects (static, dynamic, vehicle, destructible etc) as thoughs are things that should block the capsule component. If the trace hits something that blocks it, then the character should stay crouched…e.g. not execute uncrouch event.

Check your flow logic.

OK, I’m using the SphereTraceForObjects now with the Object Types being those four you pointed out, and I’ve rechecked everything else and it’s all as your screenshots are. The Trace isn’t colliding with anything however unless I make the radius larger than the capsule, then it works on walls and such but not low ceilings, and I can’t uncrouch when no longer touching the walls (the function in the Timer is Can Uncrouch right?).


Sphere trace (doesn’t collide unless the radius is larger)

Can Uncrouch (the function name has no spaces as seen in the Timer, I copy and pasted the name to it, unless that’s not the right function to call. Also doesn’t work if it’s looping or not.)

An option might be to use a trigger volume. The need you are describing is a state that is defined by a condition that needs to be set as an absolute event driven by a condition set by the environment each time it’s triggered with out being evaluated with in the animation BP

This is different as to the use of a line trace as the trigger volume is being used to define the state that the player needs to be in with in context as to the requirement of the map. In this case when the player enters the trigger the uncrouch is set with out having to be evaluated by the animation BP.

In general this is refereed to as Context Based Animation where the environment sets the state condition of the player model

End point on the trace is wrong. It needs to shoot up and reach the height of the standing capsule (capsule half height). As is it’s just spawning a small sphere at the center of the current capsule.

Turn on the debug.

Also do not Loop the timer.

That works, except for uncrouching when coming out from under the object when Ctrl is not pressed. Of course it would need to be called at some point later after the sphere doesn’t see that there is a ceiling there, which is why I had my original one run on Event Tick, although that introduced problems. How do you think I should go about this?

I would do that but I’m wanting to make a character that works without the need for level triggers, so it’s easier to make levels and there’s less to worry about when making them.

Made some changes and tested.

Added a custom event “Recall Uncrouch”

Update the Timer to call the new custom event.

Trace end point … you need to Add to the World Location Z so that the end point mirrors your standing capsule height. Half Height won’t do this.

I unticked hidden in game (rendering) on the capsule component. And manually adjusted the Z value until it fully mirrored my standing capsule.

When you crouch the half height value changes. So you need to start with the default half height + 10 cm. Should be dead on. Add a few more as a cushion.

Just as an FYI the Character Movement Component has built in Crouch and UnCrouch functionality. Does all of this stuff itself. Even has an Is Crouching bool.

1 Like

Thanks a ton, works great. I couldn’t find a way to use the default Crouch functionality with the timeline so settled with trying to make my own.