x

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 to stop AI movement after distance?

Hello,alt text I am using the simple AI Move To blueprint in the AI controller. How would I create a distance blueprint where the AI stop moving after the player is away from the AI at a certain distance? And is it possible without using the behavior tree?

Product Version: UE 4.14
Tags:
more ▼

asked May 05 '17 at 04:13 PM in Blueprint Scripting

avatar image

Baeronz46
1 1 1

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

1 answer: sort voted first

I was facing the same problem but I found out a solution.Get the world location of the AI and break it, then do the same with your character. Subtract the X of the AI by the X of your ![alt text][1]character and the Y of the AI by the Y of your character. Create a branch with the condition of if the value is less than 0 then multiply it by "-1"(to make it positive).Now Make two variables "Distance X" and "Distance Y". Plug the difference of X of the character and the AI into "Distance X" and the difference of Y of the character and the AI into Distance Y". Now as you know the distance between the characters, now make a variable "Total Distance" = (sqrt("Distance X"^2 + "Distance Y"^2)) by this you can get the distance between your characters. create a branch where you check if the "Total Distance" is less than a certain value, and if it is you stop your character by either creating an "AI MoveTo" node and set the target to itself or by a "stop movement node". Hope it helps

check.png (333.8 kB)
total-distance.png (341.6 kB)
more ▼

answered Oct 12 '17 at 03:00 PM

avatar image

IdrisKhan
1 1

(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