No announcement yet.

Adding health to an enemy inside of a class?

  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    I suggest you to check out these pieces of documentation:

    And to check out few tutorials (like this one) to get started.

    To answer your question, there are a thousands ways of doing it depending on the mechanic you want to design.

    The quickest way I would think of is the following:
    - instead of "Destroying Actor" you would call "Take Damage", it is an actor generic function that calls an event on the damaged actor. You can just specify an amount of damage and don't bother the rest (it is quite useful but too advanced for what you want to do).
    - You'll then go to your BP Box actor and create a float variable "Health" (hence the variable documentation link)
    - Implement the "EventReceiveDamage" (or something like "EventAnyDamage" maybe). Implementing this event will give you a green pin, this is the amount of damage you dealt to the Box. You can then decrement Health by the amount of damage you dealt. If it went down 0, you can destroy actor at that point.
    Last edited by Yun-Kun; 10-31-2017, 04:01 PM.

    Leave a comment:

  • started a topic Adding health to an enemy inside of a class?

    Adding health to an enemy inside of a class?

    Hi everyone. I'm quite new to blurprints, and following a worksheet, I've gotten to the point where from the default fps project, I have the boxes inside the map held inside of their own blueprint that randomly spawns them across the map in different scales. I also have it so I can destroy them in one hit of the gun that adds to the score. I now have to figure out how to add health to all of these instances of boxes so that (based on their size) it will take more hits to destroy them. The problem is, I have my area that deals with projectiles and destroying the actor in one area, and I need to have the health inside of the Box BP.

    The attached images show my projectile blueprint class, box BP and level BP. Can someone help me figure out an easy way of accessing the health and changing it when an actor has been hit. I'm guessing it would be done on the "break hit result" node, but can't figure it out. Many thanks in advance!