0
\$\begingroup\$

I have an actor who has some animations. Animations perform based on some actor states (animation blueprint of actor):

enter image description here

Conditions at the Event Tick (similar to while loop):

enter image description here

The actor changes perfectly from animation to animation. What I'd like to do is for it to damage an enemy as soon as the attack animation is over.

I tried some codes...

In this one, for example:

enter image description here

This variable (minionAtk) modifies the state of the actor. See the image below in the event (which is only called when the minionAtk is true) that I can successfully change the state of the actor (to the attacking state):

enter image description here

Animation Blueprint:

enter image description here

Transition:

enter image description here

But since the change from true to false is done instantly, the attack animation is not even shown.

To solve this, I put a delay and a condition so that the event could not be called again while the execution of cycle (attack animation => end attack animation) ended:

enter image description here

So when the actor is in the attacking state, the attack animation usually performs. After 5 seconds the animation stops.

It turns out that in this time interval the animation does not play only once.

I imagine there is a way to do the time calculation that the animation lasts, and based on that set the delay time.

But better than that, I wondered if there was no way to know when the animation was finished and from that, change the variable to false and perform the damage action.

Thinking about it I researched and found this:

https://answers.unrealengine.com/questions/329698/animation-damage.html

But I came across this error:

This blueprint (self) is not a BTTask_BlueprintBase, therefore ' Target ' must have a connection.

Error link:

https://answers.unrealengine.com/questions/549437/error-this-blueprint-self-is-not-a-therefore-self.html

I also saw something about sphere traces, attached to an actor socket. But in my case I don't want to apply the damage just in case of contact of the actor's arm (armed or unarmed) to the target, it would be something as seen in MOBA style games.

It would be like a basic attack from Garen/Yasuo/Darius.

\$\endgroup\$
1
\$\begingroup\$

I suppose you want to use AnimNotifies it is a feature of UE4, when an AnimationInstace can send an event to your AnimationBP.

You can find more info at UE4 docs:

\$\endgroup\$
1
\$\begingroup\$

"How do I make X happen if Y occurs" can almost always be answered with:

Event Handlers... Or in the case of Unreal / C++ Delegates / Event Handling. This is one of the most reliable and predictable methods for a great number of things. Events / Listeners can basically be stapled onto any piece of code and wired up to each other. Event happens, listener detects it, and applies whatever logic you put into the listener on whatever object the listener is attached to. (This logic can be as complex, or as simple as needed).

If you're dealing with multiple potential enemies: event's / listeners can be put as high up in the inheritance structure as needed, and simply validate to make sure logic is being applied to the appropriate object. (Event can carry required information from the attacker, listener then validates).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.