Search in

Sort by:

Everything Blueprint Scripting

Current Space

Question Status:

All Questions With Answer With Accepted Answer

Quick results

Search help

Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both.
Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.

You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with
each other. Examples

How can I set up an AI health system?

0

Hi! I'm pretty new to ue4 and can't find a really suiting tutorial for this.. I've a working AI that spawns on a location, walks to random spots on her nav mesh and as fast as I enter the nav mash she runs towards me.. Now to my problem.. When I wanna shoot her I need some sort of health system on her.. Now when my projectile hits I only get my print string.. What have I done wrong or have I missed something important out? I'll add some screens to my two blueprints :)

Sly edit here: Realised a better way of handing the health check, which was to deal the damage first and then have the set command execute the check after it completed. the below can now be ignored unless you wish to circumnavigate my horrible drawings and replicate the original version.

Note: For some reason, even though the value function on that blueprint is less than or equal to, it seems to only respond to less than for destroying the actor, as I had the health default set to 10 and it died after 11 bullets. That or it destroys on additional damage after it hits zero because the function to check health isn't being called until it receives damage once again after it goes below the value..

Either way, it seems to be that the best way to avoid having to do a constant health check for all actors on every tick is to just set that value to 1 so it can die on 0. Sorry if my explanation isn't all too great, but the blueprint should have all the info you need either way.

Within your actor you need to grab that input and handle it somehow. There should be a node called "took damage" or very similar which receives all kinds of "apply damage" events and allows you to calculate shields and all that stuff.

TLDR: You already deal the damage. Now you need to put a HP system behind it.

In your Projectile class when you apply damage you apply it to your player character and not to whatever got hit and you also only apply damage when the hit actor is the player character.

Just pull out the "Other Actor" line and directly put it into "Damaged Actor". You can do the checks later on at the actually hit actor... or just ignore it all together. Nothing is happening if you don't have a "took damage" node.

You need the HP system pretty much like you had it in the character with the "AnyDamage" node and for the "ApplyDamage" node just pull the "Other Actor" to the "Damaged Actor". Remember to always check where something doesn't work.

Always check if anything at all comes out of the "Any Damage" node and if you have a signal right before you use the "Apply Damage" node.

Oh and get rid of that branch. You probably don't even need the ComponentHit but can use straight up "Event Hit" and pull that straight to apply damage.

Currently you have the damage set up to hit player 0 only. You should set damaged actor to "other actor". You can also do a cast to from your actor to your ai class, then run the damage from that. This makes it check to see if what you hit was an AI, and if so, deal X damage.