x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Alternating "Attack" flipbook animations

Project Background Overview

I'm currently designing a top down paper 2d game. My player sprite is capable of moving in 4 different directions, and attacking in 4 different directions. (Up, Down, Left, Right) For each directional attack, there are 5 flipbooks. (attack_up0, attack_up1, etc )

Desired result

I'd like the animations to consecutively play one after the other. So if the player is facing up, and they press the attack button once, it will play "attack_up0" flipbook in its entirety, then, should the player press attack again, and they are still facing the same direction; it will play "attack_up1"flipbook in its entirety. This same logic would ideally apply to the other directional states as well.

Current Implementation

I have an enum of different directional states, which I check inside my custom animation state machine function to check which direction my character is moving in, and selecting the appropriate value for that direction.

alt text

If not attacking it continues the branch to see whether they are moving, or they are idle. It will update the flipbook accordingly if the player is not attacking.

alt text

Now here is where things become hazy.

I've been trying to think of a way to implement this attack system, but I'm afraid I'm going about the logic in a wrong way. I feel I have to manipulate some variables, or some flipbooks somehow in the event graph, and have that communicate with my animation state machine, but I have no idea how to go about doing that.

The screenshot below shows my attempt, My first thought was to have an integer "num swings" variable to increment every time a player attacks, to see which flipbook we are currently on. I used similar logic with comparing the last move direction to work the same as an attack direction.

alt text

There is an if/else branch, which then makes use of that "combo code" (if I continue down this logic pathway, I'd have multiple if/else branches for each attack state, what you see in this screenshot below is for the attack_up direction)

alt text

Also here is a current look at the event graph. (which I may have to add some "Sprite on flipbook end event? set looping logic? get total num frames divided by total duration? I really have no idea where to go from here.)

alt text

Product Version: UE 4.18
Tags:
more ▼

asked Feb 16 '18 at 03:58 PM in Blueprint Scripting

avatar image

nmontefusco
1 2

avatar image VJ99 Oct 06 '18 at 12:21 AM

Hey man, I'm trying to do the same thing but I'm stuck too. I know this was posted a long time ago but I was wondering if you had figured out what to do and if you'd be willing to share what you did.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question