Crouching and Swimming

Is there a way to not be able to crouch when swimming in water, as I’m stuck in the crouch position?
Can I have an answer in simple English please.
UE4-25
2022-04-22T23:00:00Z

You can use a condition to check if character is not swimming, so add a branch before the flip/flop node, get movement component, get movement mode, get is swimming and link the branch’s false output to the crouch flow, else do nothing. To simplify, if you have a boolean Is Swimming, that would be easier.

1 Like

Thanks I’ll have to try it out later

1 Like

I tried to do that, but sadly it didn’t work, stuck in the crouch when in the water, I’m swimming in the crouch position and can’t jump out of the water .

I learned about the swimming part from Matt Aspland Tutorial on YouTube.

That part at the end, of the crouch was for the capsule’s half height and capsules radius, because I hadn’t set it last time I was unable to go though small spaces.

Hi there. My understanding is that you want to block the Crouching input key if your character is swimming, correct? So, how are you setting your character’s swimming state? I mean, when your character detects a water volume, are you setting ‘movement mode = Swimming’ or only a boolean ‘Is Swimming’? Use the same variable in the branch node. Also, make sure inside your character BP, select Movement Component, open the details panel and verify if ‘can crouch’ and ‘can swim’ are correctly checked.

The swimming starts off like this, I didn’t have a Boolean for the swimming in the CatBP, I only had a Boolean used in the Animation Blueprint, in that event graph.

The code first starts off being attached to the inputAxis MoveForward, by a branch, the characters movement is, attached to a movement mode EMovement Mode Enum, which is attached to one more, Enum there I choose Swimming in the drop down list, then it’s attached to that branch.
the branch, and is linked to Forward Swimming part.

The Event on MovementMode Changed is the last part of the code added to the Swimming.

Yes I have the Can Swim ticked and Can Crouch Ticked as well

I got some really great news it’s fixed, I got shown to fix it, I had to do this in the animation graph, in the State machine, where I created a state for walk/idle.

I had to create a new blendspace, as I only had 2 one for walk/idle and 1 for swimming/idleSwim, I created a new one for crouching/crawling, attached it, having another Blend Poses by Bool, attached the variable I had created before called “Is Crouching” Blend Poses by Bool.

I had to delete a state I had attached to the walk/idle state called Crouching and another one crouch walking as this messed it up.

1 Like

Glad to know it is fixed. Keep up the good work.

1 Like

Forgot to mention the person that helped is called MatDevelop, a UE4 creator that makes videos on YouTube, the person responded to me in the comments, from their latest video called " UE 4 | TUTO Blueprint : Als Create a cop AI (Like GTA V) "
I was shown a link to an image they made, when they commented to me.
I tried to thank them, and somehow my response turned invisible, it says there’s 4 comments in comment section, but I only see 2.

1 Like