I’m trying to get a combat melee style sword combo attack setup for my game. After searching for several hours on Google and YouTube, I found a 15 min YouTube tutorial that I found relevant for what I want to do:
My character does not have a draw and sheath system as the guy in the tutorial explains how to setup, but he says the combo attack blueprint will work fine without that. He also sets up “HeavyAttack” and “LightAttack” functions.
Problem 1:
I followed everything he said to do and my character does swing the sword once with the heavy attack, but pressing the same button again quickly does not trigger the combo attack.
For extra info, I’m using the enhanced input actions system with a PS5 dual sense controller, but I already tried using a keyboard key to press the sword attack button and the same problem happens.
Problem 2:
When I press the button for the light attack, my character swings the sword once, but after that, not only can I not swing the sword again with that button, but I can’t swing it at all anymore with any button unless I restart the game.
Here are some pictures of my blueprints to show your what I did. For more info, I also have a player controller base blueprint that I created from a different tutorial, but it’s not setup to work with this current setup. If that could be causing problems, please let me know and I’ll either delete it or show pics of that blueprint.
Your sword not swinging again is probably due to the notify not being setup right somewhere.
An easier way to do this would be to add a boolean to the character called “can attack?” or some such, and set it to false when you hit attack button. From that do a SwitchOnInt or just some select nodes from an integer variable named “combocount” or whatevs. Then play a montage, using a select node hooked up to the counter int, update the count, and set canattack to false.
My input action for attack fires this event after checking other suff.
Then in your montages, add a notify where the attack anim should finish. And in the event graph of teh anim bp for the char, have that notify even set canattack back to true.
Or use a short delay/timer during the input event somewhere to reset it. One benifit of using a timer or delay with input event is you can force it to reset on a “global cooldown” essentially in case an animation gets canceled somehow.
Thanks for the reply! I’ll try this either later today or tomorrow. There’s one thing I’m wondering about though. From your first picture, it looks like the set “can attack” boolean is connected to something else that’s not showing in the picture. Is there anything that supposed to be connected to at the end?
The end of that is going to some placeholder code with a retriggerable delay which clears a bool for “incombat” so char will go into passive idle stance. Nothing that really affects the combo, per se.
Part of my attack buton logic mentioned above checks if weapon is drawn and if already in combat, then sets bools as needed.
Also, on the set combocounter node in first pic, if you have longer combos, just use counter +1 for the B pin on select. I only have 2 hits right for left/right punches and such.
I encountered problems setting things up in the Animation Blueprint.
Possible Problem 1: I could not find the variable I created called “Can Attack” that I created for the char bp, so I created a new boolean with that same name in the anime bp. Is that right?
Problem 2: I could not find the Pawn Ref node and after trying many different things, I also couldn’t figure out how to create the target pin shown in your second picture.
My pawnref var is created/set during the anim bp initialize event using get pawn owner, casting to that as my characters’ class, and the valid return for that sets the pawnref var (using my char class as the type). Not at my desktop at the moment, so can’t post a screen until later, but it’s basically like how Manny is setup in the example content. Only I named my character refrence var pawnref instead of MyThirdPersonChar or whatever they call it now.
I created a new project and looked up the Manny mannequin, studied the code, and did what you said to create and set the pawn ref var, but this is the error I got:
This way lets you fetch it quickly during anim updates without casting every time.
In my case, I have a bp_basechar which the player and npcs are all a child class of, so you’d need to change the cast type to match your character class.