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"

AI attack only when attacked

Hi guys, i am a new user of UE4 and i am trying to figure out how can i make my AI bot to start attacking (punching) only when being attacked (punched) by my character. Here's my behavior assets alt text As you can see i have set some tasks (BTT) for the bot and to be more specific here is the configuration of the two persumably assets that need to be adjusted in order to do the above mentioned:

BTT_botMovetoEnemy alt text alt text and BTT_botAttackEnemy alt text alt text

All answers are appreciated. Thank you, in advance !

Product Version: UE 4.8
01.jpg (326.0 kB)
03.1.jpg (348.6 kB)
03.2.jpg (333.6 kB)
02.1.jpg (378.9 kB)
02.2.jpg (329.7 kB)
more ▼

asked Sep 12 '15 at 12:29 AM in Blueprint Scripting

avatar image

3 2 2

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

1 answer: sort voted first


Looks like you need some kind of a value (can be a bool) which gets set when the player punches the AI. This bool can be directly linked to some value on the blackboard. Now in the behavior tree check for this value and start attacking the player (if the player is still in range).

Basically the high level steps would be :

  • In the AI blueprint check for overlap of the player weapon collider (attached to the hand for punches).

  • If an overlap is detected, set a value (maybe bool) in the blackboard of the AI.

  • In the behavior tree have a subtree which gets activated if the blackboard value is set.

  • The subtree should run the attack task where you can play the AI's attack animation.

  • Also make sure the AI is in range of the player when you run the attack subtree otherwise the AI would just keep punching even when the player is further away.

This is just an overview of how u can probably do it.


more ▼

answered Sep 12 '15 at 12:52 AM

avatar image

111 4 2 5

avatar image Apex_ Sep 12 '15 at 11:46 PM

Thanks for your response ! Indeed, i had already a boolean value to my main character BP for determining the punch montage to the respected button. So i just dragged this value and placed it in my bot enemy detection Service as a condition to a branch which allowed a triggered execution to my bot state > search and attack if true or patrol and ignore if false.

(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