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 do I create a Ranged enemy A.I?

I really want to know how to make an A.I that shoots projectiles at the player at a distance with following the Player at a Certain Distance...

Product Version: UE 4.12
more ▼

asked Mar 28 '17 at 10:10 AM in Blueprint Scripting

avatar image

6 2 3 5

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

1 answer: sort voted first

Hey there,

This is a very complex question, so first of all, i recommend learning the basics of AI using behavior trees and blackboards. Unreal's Youtube channel contains many many tutorials about this. If you feel you need something much more specific, i recommend maybe the following tutorials (NOTE: Pluralsight does give trial period but otherwise costs around 29$ a month):

Pluralsight's intro to AI navigation

Pluralsight's AI Behavior states

I found these tutorials to be very helpful, but there are many free alternatives.

Now, about your question, i can only give you the general logic:

You need to create an enemy character with an enemy AI controller. Create a blackboard and a behavior tree. Make the AI Controller run the behavior tree on EventBeginPlay.

Your behavior tree can be split up to multiple AI States, like "Idle", "Looking for enemy" and "Seeing enemy".

Afterwards, add an AIPerception component to your AI character and add a AIStimuli component to your player character. Make sure to add the exact senses to both AIPerception and AIStimuli.

Then, use the AIPerception functions to detect when a player is visible and when he is no longer visible.

If no enemy visible -> AI is Idle

If Enemy is visible -> AI is Seeing Enemy

if Enemy was visible but no longer -> start a certain timer to allow a short "search" timer and AI will be in Looking for Enemy state.

In your blackboard:

Idle can be a very basic "Wait X seconds).

Looking for enemy can be a MoveTo(lastKnownLocation) and then Wait Y seconds.

Seeing Enemy should be MoveTo(EnemyActor) until is in MinimumRange then Shoot which will be the AI Character doing all the animations and trace calculations for the shooting.

NOTE: this is as specific as possible but still very general. You need to know how to use Blackboard variables and key selectors to achieve this. So, again, i recommend learning the basics first :)

Hope this was helpful.

more ▼

answered Mar 28 '17 at 10:38 AM

avatar image

151 4 5 8

avatar image DDraiman1990 Mar 28 '17 at 10:48 AM

You can also try the free tutorials of ShooterTutorial.com.

This specific one explains just what u wanted: Shooter Tutorial first enemy BT

(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