Disable Character movement when attacking or entering other state

Hi

Im trying to figure out how to disable character movement for the duration of attack animation (or a different state, like a power up or crouch) which is set up through animation montage. Whenever I click left mouse button, attack anim plays but im also able to move and rotate the character in space with WASD keys (locomotion).

Ive created a Disable Movement variable and tried connecting it in the attack state in Event Graph, but character still moves. How would Unreal know I want to freeze the character in place with that node? Sorry if this sounds silly, Im a blueprint noob.

If Im able to complete this next thing I need is to add blend animations from run cycle to idle and from idle to run and other various blends. Also trying to figure out how to build that in state machines/ blueprints.

Thanks

edit: managed to stop the movement when performing attack animation, but cannot restore the movement, character remains disabled.

The easiest way i would imagine is to set a boolean variable and a branch after your vector movement for the character. So when true your movement is active and when false your movement is not. Then just set the variable like a switch.

Make use of the State machines Entered State Event and Left State Event for enable / disable movement stopping.

Also this should help some UE4 #4 Create 2d Blendspace for character combat mode - YouTube

1 Like

Thanks

So for the boolean method, would I need to wire this up in attack state or movement state? What I did is added disable input node with a delay of 4 seconds (to the attack state) after attack animation is set to go ahead. After delay, enable input node kicks in and I regain control over character. But for some reason the attack anim breaks and wont play again, but the delay will kick in so Im trying to figure out whats causing that. If I reset attack plays and only for the first time again.

Thanks for the links, Ive watched the video and there is definitely something that I could use from it so will try to edit or rebuild my graph tomorrow. Im not sure what you mean by enter/left state event or how it works.

From one of my Animation BPs I was playing around with the other day.

Hi

Ive tried to make it work like in your example with state events, but they are not firing. Do you have anything else set up to the movement graph in character BP that halts the movement when in attack state?

Unrelated, if you split up the idles and locomotion animations into different states, what are the blending results? Are you able to add specific blend animations from one state to another?

Do these work as you want?


Begin Object Class=K2Node_VariableGet Name="K2Node_VariableGet_1"
   Begin Object Class=EdGraphPin Name="EdGraphPin_20465"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_20466"
   End Object
   Begin Object Name="EdGraphPin_20465"
      PinName="CharacterMovement"
      Direction=EGPD_Output
      PinType=(PinCategory="object",PinSubCategoryObject=Class'/Script/Engine.CharacterMovementComponent')
      LinkedTo(0)=EdGraphPin'K2Node_CallFunction_2272.EdGraphPin_20473'
      LinkedTo(1)=EdGraphPin'K2Node_CallFunction_2574.EdGraphPin_27879'
      LinkedTo(2)=EdGraphPin'K2Node_CallFunction_2575.EdGraphPin_27882'
   End Object
   Begin Object Name="EdGraphPin_20466"
      PinName="self"
      PinFriendlyName="Target"
      PinType=(PinCategory="object",PinSubCategoryObject=Class'/Script/Engine.Character')
      bHidden=True
   End Object
   VariableReference=(MemberName="CharacterMovement",bSelfContext=True)
   Pins(0)=EdGraphPin'EdGraphPin_20465'
   Pins(1)=EdGraphPin'EdGraphPin_20466'
   NodePosX=784
   NodePosY=-352
   NodeGuid=0EDA94BE43717CFBFCAF37A67515534D
End Object
Begin Object Class=K2Node_CallFunction Name="K2Node_CallFunction_2272"
   Begin Object Class=EdGraphPin Name="EdGraphPin_20471"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_20472"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_20473"
   End Object
   Begin Object Name="EdGraphPin_20471"
      PinName="execute"
      PinToolTip="
Exec"
      PinType=(PinCategory="exec")
      LinkedTo(0)=EdGraphPin'K2Node_CallFunction_2574.EdGraphPin_27878'
   End Object
   Begin Object Name="EdGraphPin_20472"
      PinName="then"
      PinToolTip="
Exec"
      Direction=EGPD_Output
      PinType=(PinCategory="exec")
   End Object
   Begin Object Name="EdGraphPin_20473"
      PinName="self"
      PinFriendlyName="Target"
      PinToolTip="Target
Character Movement Component Reference"
      PinType=(PinCategory="object",PinSubCategoryObject=Class'/Script/Engine.CharacterMovementComponent')
      LinkedTo(0)=EdGraphPin'K2Node_VariableGet_1.EdGraphPin_20465'
   End Object
   FunctionReference=(MemberParent=Class'/Script/Engine.CharacterMovementComponent',MemberName="DisableMovement")
   Pins(0)=EdGraphPin'EdGraphPin_20471'
   Pins(1)=EdGraphPin'EdGraphPin_20472'
   Pins(2)=EdGraphPin'EdGraphPin_20473'
   NodePosX=1328
   NodePosY=-544
   NodeGuid=83EF64824C51ECEAD085CBB6DBCF8664
End Object
Begin Object Class=K2Node_InputKey Name="K2Node_InputKey_202"
   Begin Object Class=EdGraphPin Name="EdGraphPin_27378"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_27379"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_27380"
   End Object
   Begin Object Name="EdGraphPin_27378"
      PinName="Pressed"
      Direction=EGPD_Output
      PinType=(PinCategory="exec")
      LinkedTo(0)=EdGraphPin'K2Node_CallFunction_2574.EdGraphPin_27877'
   End Object
   Begin Object Name="EdGraphPin_27379"
      PinName="Released"
      Direction=EGPD_Output
      PinType=(PinCategory="exec")
      LinkedTo(0)=EdGraphPin'K2Node_CallFunction_2575.EdGraphPin_27880'
   End Object
   Begin Object Name="EdGraphPin_27380"
      PinName="Key"
      Direction=EGPD_Output
      PinType=(PinCategory="struct",PinSubCategoryObject=ScriptStruct'/Script/InputCore.Key')
      DefaultValue="AnyKey"
   End Object
   InputKey=Three
   Pins(0)=EdGraphPin'EdGraphPin_27378'
   Pins(1)=EdGraphPin'EdGraphPin_27379'
   Pins(2)=EdGraphPin'EdGraphPin_27380'
   NodePosX=800
   NodePosY=-528
   NodeGuid=8553356B4A65E6B85A9290B33B674CC3
End Object
Begin Object Class=K2Node_CallFunction Name="K2Node_CallFunction_2574"
   Begin Object Class=EdGraphPin Name="EdGraphPin_27877"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_27878"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_27879"
   End Object
   Begin Object Name="EdGraphPin_27877"
      PinName="execute"
      PinToolTip="
Exec"
      PinType=(PinCategory="exec")
      LinkedTo(0)=EdGraphPin'K2Node_InputKey_202.EdGraphPin_27378'
   End Object
   Begin Object Name="EdGraphPin_27878"
      PinName="then"
      PinToolTip="
Exec"
      Direction=EGPD_Output
      PinType=(PinCategory="exec")
      LinkedTo(0)=EdGraphPin'K2Node_CallFunction_2272.EdGraphPin_20471'
   End Object
   Begin Object Name="EdGraphPin_27879"
      PinName="self"
      PinFriendlyName="Target"
      PinToolTip="Target
Movement Component Reference"
      PinType=(PinCategory="object",PinSubCategoryObject=Class'/Script/Engine.MovementComponent')
      LinkedTo(0)=EdGraphPin'K2Node_VariableGet_1.EdGraphPin_20465'
   End Object
   FunctionReference=(MemberParent=Class'/Script/Engine.MovementComponent',MemberName="StopMovementImmediately")
   Pins(0)=EdGraphPin'EdGraphPin_27877'
   Pins(1)=EdGraphPin'EdGraphPin_27878'
   Pins(2)=EdGraphPin'EdGraphPin_27879'
   NodePosX=1024
   NodePosY=-544
   NodeGuid=DD80B4844FE5843B2F948F89173B021E
End Object
Begin Object Class=K2Node_CallFunction Name="K2Node_CallFunction_2575"
   Begin Object Class=EdGraphPin Name="EdGraphPin_27880"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_27881"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_27882"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_27883"
   End Object
   Begin Object Class=EdGraphPin Name="EdGraphPin_27884"
   End Object
   Begin Object Name="EdGraphPin_27880"
      PinName="execute"
      PinToolTip="
Exec"
      PinType=(PinCategory="exec")
      LinkedTo(0)=EdGraphPin'K2Node_InputKey_202.EdGraphPin_27379'
   End Object
   Begin Object Name="EdGraphPin_27881"
      PinName="then"
      PinToolTip="
Exec"
      Direction=EGPD_Output
      PinType=(PinCategory="exec")
   End Object
   Begin Object Name="EdGraphPin_27882"
      PinName="self"
      PinFriendlyName="Target"
      PinToolTip="Target
Character Movement Component Reference"
      PinType=(PinCategory="object",PinSubCategoryObject=Class'/Script/Engine.CharacterMovementComponent')
      LinkedTo(0)=EdGraphPin'K2Node_VariableGet_1.EdGraphPin_20465'
   End Object
   Begin Object Name="EdGraphPin_27883"
      PinName="NewMovementMode"
      PinToolTip="New Movement Mode
EMovementMode Enum

The new movement mode"
      PinType=(PinCategory="byte",PinSubCategoryObject=Enum'/Script/Engine.EMovementMode')
      DefaultValue="MOVE_Walking"
   End Object
   Begin Object Name="EdGraphPin_27884"
      PinName="NewCustomMode"
      PinToolTip="New Custom Mode
Byte

The new custom sub-mode, only applicable if NewMovementMode is Custom."
      PinType=(PinCategory="byte")
      DefaultValue="0"
      AutogeneratedDefaultValue="0"
   End Object
   FunctionReference=(MemberParent=Class'/Script/Engine.CharacterMovementComponent',MemberName="SetMovementMode")
   Pins(0)=EdGraphPin'EdGraphPin_27880'
   Pins(1)=EdGraphPin'EdGraphPin_27881'
   Pins(2)=EdGraphPin'EdGraphPin_27882'
   Pins(3)=EdGraphPin'EdGraphPin_27883'
   Pins(4)=EdGraphPin'EdGraphPin_27884'
   NodePosX=1328
   NodePosY=-368
   NodeGuid=3FF3C4104099201709118582AAA00F88
End Object


hey

Havent really tested that because I started to build a root motion controller. Im new to that so no idea what all the nodes mean, just following the instructions on here [Tutorial] UE4 Root Motion Controller 01 - New project, basic movement - YouTube

Its working to an extent, but left and right buttons are not functioning at all, so the character is only able to turn left and right by turning the camera, but its a very weak response although that its probably connected to the root motion of the animation? So I have my skeleton running 300 maya units in Y and X axis and turning 90 degrees, but its not the same in UE4. If I turn the camera and look at the front/side view of the skeleton while moving the effect is much more significant. Controls working inverse?

I have this in my player control [in my specific case left click was going to by move and right click was going to be an attack]

(project is topdown template based) Player enum variable is something specific for one of the bug tests I was doing. As for the other thing its hard for me to say because haven’t touched animation side of things too much.

I dont know what method to use, either try and troubleshoot root motion which may look better in the end or stick to user input driven capsule which is not easier to work with, but I still need it to function as a decent controller, be able to walk, run, enter a few buff up states which change the types of attacks available. But it also needs to be expandable further like feet IK or directional leaning.

Apologies for the necro but Google led me here so I thought I’d post for posterity:

Personally I would streamline this by creating custom notifies in your animation and then inside your AnimBP when the notify happens, you can disable or enable movement in your character pawn.

Step 1: Create two custom events in your character pawn called EnablePlayerMovement and DisablePlayerMovement and connect these to a disable movement and set movement mode node from your character movement component.

Step 2: Create the notifies where you want them in your animation.

Step 3: Run your Enable/Disable Movement events from your AnimationBP on the notifies.

2 Likes

[deleted by user]