Don't allow to uncrouch under a structure

Hey,

I had a busy day today, so I apologize if I can only reply to you now, I implemented both the walk event and the notes listed in your previous message, but something I think went wrong…

I’ll show you


Hi there
No problem, just to help you out, make sure to add all default values for these variables as initial values such as isn’t sprinting set to true, fp max walk =450, fp max sprint=650 etc.

On event walk, add a “set isn’t sprinting” to true.

Once you’ve finished, playtest it and let’s review crouching. I see too many booleans that should be reduced later on.

Are you following any particular FP Tutorial series?

Hey,

I entered all the values for sprinting and walking and set “Isn’t Sprinting” to true as the initial value and in the walk event.

I also added an Event BeginPlay because I was in the playtest, the character was going at the same speed as when he is sprinting, for now, this fixes the problem.

Regarding FP tutorials, I’m not sure what you are referring to, but I followed this tutorial in which, the booleans were named with this name:
(Blueprints and Gameplay for Game Designers | Course)

Hi
I mean First Person tutorial.

Good to know walk-run it’s working. Now let’s proceed with crouching controls without tracing structure above. We add this lastly.

Try to sort things out using the same approach and let me know if works. Here’s a hint, you have two options: crouch input cancels sprinting or crouch input is blocked if sprinting “is pressed”. Take your pick.

Also, make sure input action sprint “released” should check if “isn’t sprinting” is false before calling “walk event”.

I don’t seem to have followed any particular tutorials for the first person and thanks for making me understand the acronym! I only followed a tutorial regarding head bobbing, however, I performed everything you told me and it seems to work correctly: When the player presses the sprint input and the player subsequently presses the crouch input, it crouches, vice versa for when you press the crouch input and subsequently sprint, the player starts his run.
I attach the screens of how I reasoned:


1 Like

I would like to point out that I completely excluded the Capsule Trace By Channel part, as a result, the character when crouching and releasing crouch input or running, gets stuck.

You mean, gets stucked only if is underneath a structure, correct? If so, that’s expected. Let’s add this feature after fixing your core controls.

That’s looking really neat and organized. Well done. Use this approach for your next features.

My notes on input action crouch:
In the branch, isn’t sprinting check, both true and false lead to crouch event. Is that what you really want? Do you want to cancel sprinting with crouch input or block crouch input if is sprinting?

Hey,

Yes I mean it gets stuck under a structure, oops I didn’t realize I linked that branch to the same thing, I fixed it and got rid of some remaining bugs.
Anyway, yes, I would like the sprinting to be cleared once the crouch button is pressed and vice versa, in my opinion this would make the movements smoother.

1 Like

Good. Have you figured that out? Take a look at sprint input.

Hey there,

I tried to fix the sprint input the way in the screen below, anyway I wanted to thank you for trusting me, these days it is very rare to find someone like that!

1 Like

No problem. I am glad to help you. If you have a good start, you’ll move forward in the right direction.

Have you fixed both inputs? Have you found any glitches or undesired behavior?

I thought the input action run was completed and validated, now you’ve removed the event uncrouch from the pressed’s 1st branch. Is that correct?

I did a playtest and it seems that everything is correct and functional, I removed the uncrouch from the first branch because I thought that when you are crouched the fact that you can’t run is also better in terms of being under a structure, however if there is a way to disable any player raising due to the sprint input, I will fix everything as before!

Thanks for confirming. Can you please share screenshots of the final version of your both input actions? We’ll move from there.

Next, create a custom event “check can uncrouch” and plug your previous capsule trace per channel. The “algorithm” logic is the following:
2.3. If player goes underneath a structure while crouching:
2.3.1. Cannot uncrouch (“can’t uncrouch”)
AND
2.3.2. Sprint won’t disable crouching (“can’t sprint”)
AND
2.3.3. Player will trace a blocking structure overhead whenever is crouching using a looping function

The only major change is that we need to call that “check can uncrouch” using a “looping” function every 0.1 seconds while crouching and disable that looping function if not crouching. We are going to use a node called “set timer by function name”. Do a little research and we discuss it tomorrow. So, try to figure this workflow out and I’ll be back tomorrow to check your progress.

Hope that makes sense.

Of course! I’ll send you the crouch and sprint inputs right away, I’ll also attach the new custom event linked to Capsule Trace By Channel, unfortunately though, I stopped here, I didn’t quite understand how to continue…
In the meantime, I’ll try to inquire about the looping issue because I want to know more!


Hi there,

During a playtest, I noticed a kind of bug that happens when the character is crouching and presses the sprint input, this would assume that the character would get up and start running right away, but even if the input is pressed, the character will just uncrouch, I thought that just one more branch when releasing the crouch input with condition Isn’t sprinting? and if it was true it would just get up and if it was false it would just get up and start running was enough but nothing changed, I assumed the problem was related to the fact that when crouching the sprint is cancelled and a new input is sought to restart it, not sure if that makes sense.

Anyway, I don’t want to fix this, the character movement is affixed like this, it was just out of curiosity

Hi there,
Judging by your last screenshots shown in your post #36, I believe this bug happened because you removed the uncrouch call from your input action run “pressed”, comparing your post #36 as it was in your post #25. You also removed the event sprint call from your crouch input “pressed”.

Let’s review the trace and looping functions as soon as you confirm and validate your run and crouch inputs. It’s really important to fix your core controls first before adding more features. That will avoid more bugs later on.

Remember, you need only two functions more to complete your first gameplay mechanics.

Hey,

I think I removed the uncrouch call from my sprint input because I didn’t want the player to get up while the crouch input is pressed, however, I was trying to create a logic in which when the player is crouched he can’t get up, but if you press the sprint input while he is crouched, upon release of the crouch input, the player would directly start the sprint, without him simply getting up, to avoid a new press of the sprint input, I don’t know if I was very clear

Hi there

I see. Remember all these automatic input options might make your logic too complex as a starting point.

The sprinting will be blocked while crouching underneath a structure using a new variable type boolean “can uncrouch?” using the logic in the next functions below.

For the trace function “check can uncrouch”, after the capsule trace, delete everything left over, connect a branch directly and connect the red pins, create a new variable type boolean “can uncrouch?”, then:
If true (meaning there’s a structure above), set “can uncrouch?” to false
If false set “can uncrouch?” to true

Now, the looping function will be done as follows:
Get the event crouch (the red one) and connect a “set timer by function name” in the very end. Then, set function name to “check can uncrouch” by editing the squared text input. The name of the function need to match exactly as your custom event, including spaces, if any. Then set time as 0.1 and check looping to true. After the timer, click on blue output pin and right click, promote to a variable and rename it as “uncrouch timer” or something else you like and connect the white wire. Now the event crouch is completed.

Get event uncrouch (also the red one), and in the end of it, get the new variable (“get uncrouch timer”) and connect it to “clear and invalidate timer” and connect the white wire. Then, uncrouch event is done.

Input action run, “pressed”, you just need to connect “can uncrouch?” to a branch in the very beginning of the flow, before everything. Connect the rest of the flow to the TRUE output.

Input action crouch, “released”, add a branch with a “can uncrouch?” In the very beginning and connect the rest of the flow to the TRUE output.

Now, give it a try and let me know if all this makes sense.