Player Not Damaging Enemy With Animation

Hey guys, I have been trying to get my player to damage the enemy with my fight animation for my player. However, it is not damaging the enemy unless my player bumps into it repeatedly, which also deducts my player’s health. Is there something I am doing wrong in the code? Is there any way to do it properly? It is a top-down game, fyi.
Game: HighPower Game

You need to at least create an object for dmg enemy. Ex: Slash, Bunch, Player’s Bullet…

What you could probably do is use an Emit connected to the space so that when the animation plays, you could punch him. And if you want it to make it look like it’s not sending anything out, you could take whatever object you’re emitting and put Alpha at 0% (putting in no sprite will not work)

If you’re still stuck, I’ll give you a picture

Then, add some Collision behaviors that settled to Collision with those objects that you want enemies to get dmg from. And now you just need to add some Number behaviors as DMG(negative number, ex: -5) and another Number behaviors for amount of enemy’s HP (positive number, ex: 10)

After all of that, the only you thing left you need to do is use Emit to emit those object when you activated the Animation behavior.

1 Like

I just want my player to just punch and not emit anything. Although I don’t know if there is any way for him to do that without emitting anything. Is there a way to do punches not emitting something?

1 Like

@Emy254 I got you!

Code pictures and where I placed them

Players health

Players attack (Turn off repeating on spacebar)

Enemies health

Just to clarify:

Things to know about this
  • Since collisions happen once, I used a proximity instead so you can keep hitting it. I also put it at 25 because if it were larger, you would hit it without touching it

  • Switches can be important because they either allow a code to go through, or they won’t allow them to go through

  • I strongly recommend you name the globals exactly how I named them because globals are like messages to mailboxes, except instead of sending one at a time, they send to every other globals as long as they have the same name in them. If you named them all one thing in this case, it’ll cause some problems so that’s why I did 2 different names

1 Like

Thanks, it works now!

1 Like

I also have another issue: I want a sphere to receive damage from the player. The sphere is supposed to be stationary, but the health doesn’t go down once the player punches it. I set up the code for it, but is this good?
Screenshot:

1 Like

Most of it I guess :+1:
You can use the exact same coding as the enemy’s health, except set the proximity distance to 11. Also, I recommend setting the globals back to “attack” and “no attack” because there isn’t a global code that sends “Take Damage” and “No Damage.”

1 Like

Now, I have another issue. I created more types of enemies for the player to attack. How can I make all of them do damage to my player? The other enemies I have added are the Elite Draum and Giant Draum.

1 Like

(Very sorry for the late reply on this.)
Do you still have trouble with multiple enemies attacking? I looked over the other topic you created and it seems to be working out.
Multiple Enemies Attack Player