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 do I detect the player clicking again and cancel an AI task?

What I am trying to do is to have the player character walk to wherever the mouse is clicked. I can move the player to the click location using a behaviour tree. The only problem is that if I click again the character will keep moving towards the last target.

How do I make the character change path? I have tried setting up some way for the game to change the condition that makes the character move so it will reset the tree and make them move towards the new location but I'm not getting anywhere.

Are there any good tutorials for this?

Product Version: UE 4.14
Tags:
more ▼

asked Jan 04 '17 at 03:37 AM in Blueprint Scripting

avatar image

Althaen
166 13 19 32

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

1 answer: sort voted first

If you are controlling the movement manually (clicking specific target points) without any other 'behavior' involved, you don't need the behavior setup to handle it.

You can just use a single cast to the AI character with the target. Something as simple as... set path

Calling it will interrupt and replace any existing pathing.

The Mod Range is lets you pick a random point within that distance of the actual target to try to move to. It helps prevent swarm-jamming and keeps things a but more 'natural' by adding a minor "random" element.

setpath.png (62.4 kB)
more ▼

answered Jan 04 '17 at 04:19 AM

avatar image

Looniper
766 22 7 36

avatar image Althaen Jan 04 '17 at 05:25 AM

Wow I didn't even realize it was that simple. Thank you so much! Saved me anymore headaches.

avatar image Looniper Jan 04 '17 at 10:53 AM

Glad you found it helpful.

Behavior Trees are vastly superior when you have to deal with Stimulus - Response, but for simple movement, the various MoveTo nodes are just easier.

(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