Play once death animation ?

Hi,

I have a small problem regarding the death of my character.

I have a blueprint (which is a ground trap) with a box collision that inflicts damage on the character. I have a second blueprint (identical to the first) which corresponds to a monster which pursues the character.

If the life points reach 0, the character dies and an animation plays. The problem is that if the character dies in the blueprint of the trap which therefore triggers the animation and if the monster then arrives, the death animation is played a second time.

How can I make sure that the animation when he dies doesn’t play a second time if the monster touches the character who is already dead?

Thank you very much for your help.

1 Like

Hello!

Okay, so I usually do NOT play an animation. I’ll use a montage, instead. You have greater control over montages than animations.

You’ll create a Boolean that tests for if the animation montage is playing. Then it will IMMEDIATELY set the condition from FALSE to TRUE, preventing any replays of the animation.

OR

You can use a sequence to circumvent the fact that the animation node requires the animation to come to a FULL END before allowing you to proceed to reset a variable. You can add a delay before setting the variable back, depending on your needs.

Hi,

Thank you for your answers.

I tested the first and it works but the problem is that it works in the blueprint of the box collision. In this blueprint, I initialize the number of damage. So I can’t add that to the sequel otherwise the character would die each time without taking into account the damage figure of the box.

I should add that to the blueprint of my function.

But in the function I can’t use “Play montage” or “delay”.

1 Like

I think you’re over-complicating this.

You don’t need a function for this task.

If you are trying to tidy up your code, then you can COLLAPSE a set of nodes into one node, which, in essence, makes it look like a function.

Functions are not made to be dynamic. They’re made to run the EXACT same way every single time.

I would pull the code out of the function, and maybe create a CUSTOM EVENT instead.

That way you can use the Montage.

By the way, I still don’t understand why you cannot use the Sequence? It’s functionally identical to the other string of code I sent you.

Maybe show me a screenshot of how you set it up.

I understand custom events well, I have already used them in other blueprints like here to play a sequence when the correct answer is validated for a riddle.

I created the death custom without any problem but I can’t really understand where I place it in relation to my damage management.

Here is my blueprint with the box collision which inflicts damage.

Here in my character it is my damage function which checks the character’s life points and if the points are at 0 the character dies and displays a widget.

I didn’t make a mistake though

Ah! I see what I did wrong.

I forgot that a sequence fires code ONE AT A TIME, not ONE AFTER THE OTHER.

I’m going to eat and come back to this, unless someone “beats me to the punch”.

Okay, better now.

Dude, for what you want, you need to use an Animation Montage.

And the reason for this is because the timing of the death is always going to change.

Again, functions are meant to run the same EVERY SINGLE TIME. That’s what makes them reliable.

You need to pull this function out of the… well, function, and input it into the main Event Graph.

Again, you can COLLAPSE the nodes, which essentially makes it look like a standard function.

Hi,

I created a Blueprint with 2 custom events, one to display the menu when the character dies and a custom event to play the montage.

Then, my function I used a “Get all actor of class” node to retrieve the 2 events (the montage and the menu) but there it doesn’t work. The montage is not played and the menu is not displayed.

1 Like

Good morning/afternoon!

Try it with “Get Actor Of Class” not “Get All Actors Of Class”.

Hi,

Unfortunately that doesn’t work either.

Did you place the object/blueprint in the level?

You can attach a print string at the end of the function to check that it is firing.

You mean the 2 Customs Events that I created?

No, I created a new blueprint.

I don’t have anything in the level blueprint.

Usually I find the solution quite quickly but here it doesn’t work.

No, I meant your function “Degats Lave”.

That’s a separate blueprint from BP_Menu_Mort, no?

If so, it needs to be placed in the level, first.

But also, place a string at the end of the function to make sure it’s firing.

The function “Degats Lave” is found in the character Blueprint
like the death function.

I have another blueprint with a collision box which calls the function “degat lave” which allows me to choose the number of damage

If “Delgats_Lave” and “Mort_Lave” are in the same Blueprint, you don’t need to get actor of class. I think you know this already.

Anyway, I’m going to say this again, place PRINT_STRING nodes at the end of all of the functions. You need to track down what is firing and what is not.

Replace the text with whatever you want.

If all of the text gets printed, then let me know.

If not, then there’s an issue with one of your references.

Yes ok I will do it like this.

I’ll keep you up-to-date.

1 Like

Hi,

Due to issues with UE5.2 I updated to UE5.3 and created a very simple blueprint and everything works there :

Thank you very much for your help it helped me a lot.

Besides, I have another question but I will open another post. It’s also not a complex problem but I don’t really know how to correct the problem.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.