Need Help With Attack System

Greetings!

I have a simple attack system in which when you press E, it switches to the next attack. There are 7 attacks and I can’t figure out how to make a system for it. Here’s what I tried, but it doesn’t seem to work.

When I press E the 2nd time, the first attack somehow comes back and it gets stuck there. Hope someone can help!

You’re not adding to the attack index. Pull off a pin and type ++, you’ll find ‘increment int’.

2 Likes

I think I see the issue. Let’s say your “Next Attack” variable is equal to 0. If you press the “E” key you would do 0 + 1 = 1 which will trigger the attack on slot 1 in the switch node. Since “Next Attack” is still 0, pressing “E” again will still be 1.

The way to fix this is to add 1 to “Next Attack” before you play the animation. That way after playing the first attack, your “Next Attack” variable is now 1. Pressing “E” again will be 1 + 1 = 2 which will play the animation on the slot 2 of the switch node. Do this for all the slots and then on the last attack of your combo you want to set your “Next Attack” variable to 0 so it will loop back to the first attack.

Hope This Helps! :+1:

Thanks for that! Its working now!

1 Like