I am trying to add a health system to my bot that can be damaged by a player shooting at it with line tracing. What is the best way to do this?
Easiest way to do it (via line trace) is to set a float variable ‘Health’ in your bot class. Then check if the line trace has hit, if so, deduct a set amount of health.
After hit has been detected; then use a function in your bot class (like the one shown) to deduct the damage from the health. I use a branch in the example to ragdoll the AI when health <=0.
Hope it helps. ^^
Take a look at this doc page: UE4 Damage Docs
While you still need to subtract the damage amount from your health variable, there are Apply Damage nodes, if you use the Damage Type you can then do different things depending on what type of damage. Because the system is built in, it really is the easiest way to do it, in a way that you won’t be stuck when you want to handle a different type of damage.