Melee attack damage

Hi everyone,
a tip on how to manage the melee attack…
I’m currently using a simple once trigger but if the enemy is hit in the animation frames the damage is created multiple times.
How can I cause damage only once?

It might have something to do with the trigger once being placed incorrectly, try placing it on the event with conditions.

Yeah, what PiercingGames said.
Also I noticed you placed a 4(?) frame window. Like, >5 and <10, you have frames 6, 7, 8, and 9. that may trigger that event. I’m not really sure if each one of those would trigger your event. I could be wrong, of course. But might I suggest setting a boolean variable for the hit?

Maybe something like:

If arma15 is in collision with nemici
variable takingdamage is false
animation frame is > 5
animation frame is < 10

set variable takingdamage to true
Create object text damage

Then have another event where if melee animation is completed,
the variable takingdamage is once again set to false.

this is what I tried to do but the enemy damage variable remains true.
I can’t make it go back to being false

This would suggest that the “shot” animation of arma15 never gets to finish. Do you set it elsewhere?

An alternative is to have a condition at the same level as the first on in your screen snip, and check that animation of arma15 is not “shot”, add a trigger once and set enemies Damage to false as the action.

Yeah, like MrMen stated, maybe check if your shot animation is set to loop, or you might have another event that changes the animation before it could finish.

New event outside of the shot animation condition might go something like:

If damage variable is true
Animation is not “shot”

Set damage variable to false

On a different note, that variable check placed as a sub-condition under the collision check is kinda bothering me for some reason. I don’t know why. Lol. But hey don’t mind me. As long as it works.

yes you are right guys the problem is that the animation is never finished due to this event.
for now I’m setting the boolean variable to false in the penultimate frame of each weapon

I also tried as suggested by @Levio but if the animation is played in continuous sequence without ever stopping the boolean variable does not return false

Uh, hang on. What I meant was to check to see if your animation is set to loop, it probably should not be. That loop box should be unchecked. But I did use the word “check”, I think that’s where it must have got confusing. lol.
Yeah, being set to loop means, it’s not going to get finished by itself. So yeah uncheck that box.

So I also made a test version of your events just to be sure. It works on my end so if it still doesn’t work on yours, I may be at a loss.

1 Like

Hi, thank you for taking the time to understand where the problem was.
weapons when they are on the ground their animation is 0, when the player collides with the weapons they change animation to 1.

(I tried to add the once trigger but the animation still doesn’t end)

while this is my weapon attack type event… there is nothing else

at the moment I duplicated the last frame of the attack animation so as to end it anyway and set the boolean variable to false in the penultimate frame of the animation and it seems to work the same.

do you think this could make the game heavier?

I have to admit I am kind of lost as to what’s going on but I’ll try to dissect some of your events that I could.


I’m assuming that this one is referring to animation 0? Because it looks like it will cycle through animation 1 repeatedly when it’s done with animation 0.
I imagine it might go something like, "animation 0 is finished? set it to 1… animation 1 is finished? set it to 1 again… 1 is finished? yeah, set it to 1 again. Trigger once won’t stop it because every time the animation is finished (regardless which animation it is), it’s a new event when it resets.
But if that is a sub-event of a specified animation (animation 0, I presume), then please ignore what I said. lol.
If however, it’s not a sub-event of a specified animation, then I might suggest you specify which animation that’s supposed to finish in order to trigger it. Like maybe either making the “animation of arma15 is finished” as a sub-event of the referred animation or putting together the two conditions:
"If the animation of arma15 is “grabweapon”
“The animation of arma15 is finished”

As for this part, let’s see…
Event 1
“The animation of arma15 is finished” - again, which animation is this referring to?
If it’s a sub-event of a condition "If animation of arma15 is not ‘shot’ ", event 2 will not get triggered because of the change of animation.
If it’s not a sub-event of said condition, then event 2 will probably work but event 1 will keep triggering every time shot animation finishes.
Suggestion would be to specify which animation that is supposed to finish.

Event 2
Start or reset timer will stay at 0 unless animation shot is changed. Now here, a trigger once might be able to fix that.

Event 3
Trigger once might not be necessary since the variable change to false should prevent it from triggering again unless the variable is changed back to true. But if that part works, yeah, keep it.

I feel like my explanations are way too messy, sorry about that. But with all that out of the way, you say that you duplicated the last frame of the attack animation and that fixed it? Interesting, but if it works, it works. lol. Would it make the game heavier? I imagine the impact would be negligible. Though mind, you, I’m not an expert or anything, I might be wrong about all these. If the game started hogging all the device resources, we might need to ask a professional.

1 Like

Thanks Levio for the accurate explanation of the events. I have tested but it seems that I will have to leave the deselection of the variable to the penultimate frame because there are weapons that when picked up have a loop animation, so the animation never ends. If it causes me problems in the future I will come back to it. thank you so much

1 Like