Search in
Sort by:

Question Status:

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
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How can I track AI's death?

How can I make it so when my 3 AI's die (Health integer gets to 0) the level simply restarts or loading another level.

Product Version: UE older version
more ▼

asked Mar 14 '17 at 02:43 AM in Using UE4

avatar image

80 11 16 21

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Try something similar to what's in the picture provided. For this example I declared the function within the Player Character's Blueprint, which is named FirstPersonCharacter.

To give this functionality for your needs, you'll need to call this function before the AI is dead from the AI's blueprint using a cast to the player character's blueprint. The cast can be done by "Getting" the Player Character node and then dragging out the actor output and releasing in the graph and then searching for your Player Character's blueprint, for my example I would need a "Cast To FirstPersonCharacter" node and then from the Cast, drag out a node to the graph, release and type "Call Add Enemy Count" and your newly created function should pop up.

Keep in mind if you named your function something else, you'll need to "Call" whatever name you used for your function

alt text

add_enemy_count.jpg (175.5 kB)
more ▼

answered Mar 14 '17 at 03:17 AM

avatar image

46 1 2 3

avatar image Sntfon100 Mar 14 '17 at 03:43 AM

THANK YOU SO MUCH!!! Didn't know functions can be so useful haha I need to use them more now. Btw I think you made a tiny mistake in your screenshot, 2 of your equations are wrong the less then 2 and less or equal to 3 it should be the opposite :p Anyways thank you!

avatar image FrostDog Mar 14 '17 at 05:14 AM

Ahh yes haha sorry about that! But I'm glad this worked for ya!!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Create a public integer variable to allocate the amount of AI deaths. For each dead AI, increment this variable by 1 in its own blueprint. In the third person map blueprint, make an event tick with a branch that checks if the variable is equal to 3. If it is, restart the level or load another one.

more ▼

answered Mar 14 '17 at 02:54 AM

avatar image

6 1 3 5

avatar image Sntfon100 Mar 14 '17 at 02:57 AM

I've already tried it, the problem is that I want when AI's health gets to 0 to destroy actor, and what that does it resets the integer back to 0.

avatar image Sntfon100 Mar 14 '17 at 03:47 AM

Somebody just helped me with my problem but in a different way. I still want to try yours, I think I did something similar but a bit different. Like where do I create the Public integer variable and what do you mean increment it in its own blueprint? Shouldn't I do it in AI's blueprint?

avatar image TheGreater Mar 15 '17 at 03:16 AM

The public variable is created on the level blueprint (in the top bar, go to Blueprints -> Open Level Blueprint), and yes, you increment the variable on the AI blueprint.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question