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"

AI conditional choose between 4 chairs

I am trying to make some kind of simulations with 4 chairs and AI controller driven characters that can make desicion based on 1st nearest chair where I compare the distance between character and actor(chair) with get distance to actor node and the 2nd condition is something that I cant manage. If chair is busy, I place trigger volume infront of it in a actor blueprint, boolean variable lets call it "busy" gets true. so its being excluded from array of actors(chairs). this is how I think it can be done. But when i fire ai controller at the second time "busy" gets false again. I am new in blueprints. Maybe there is some better way to solve this problem?

Product Version: UE 4.21
Tags:
more ▼

asked Feb 25 '19 at 05:17 PM in Blueprint Scripting

avatar image

Salikhov
1

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

2 answers: sort voted first

what your trying to do is actually quite simple. first lets start with your second condition. you say you want any busy chairs to be excluded from the array of actors but its much easier to just exclude them from the result by using a simple check. to begin you will get a array of all the possible chairs by using something like the get all actors of class node, then you run a loop to determine the best result. in the loop you have conditions that must be met and have a variable which holds the current best result / actor. so for every actor you first test is it busy, if yes you ignore it and move on, if no then you move on to the next check. ok now for your first condition of distance to character. this one is pretty easy too, you just need to compare the distance of the current closest to the actor being tested in the loop, then set the current closest variable based on the result. see below picture for a basic example.

alt text

capture.png (308.7 kB)
more ▼

answered Feb 26 '19 at 02:21 PM

avatar image

ThompsonN13
10.1k 33 10 25

avatar image Nebula Games Inc Mar 01 '19 at 04:39 AM

Many people have needed a way to "get nearest/farthest" this or that so I created this node to perform that action internally and output the sorted array (near to far or far to near, you choose) along with the distance to the target actor if you need to use that for any reason. It will be quicker for looping through the array output from "get all actors" since it will be performed in C++. The only thing you will need to add is the boolean check. Below is a screen shot of the node and a link to a tutorial showing you how to create it. Hope this helps.

https://youtu.be/cWesVY0zF0U

alt text

distance-sort.jpg (87.7 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Thank you all For checking distance this solutionas are great

Second condition solved my primitive way I could by the time. Created actor blueprint with boxcollisn components that I then placed around each chair and called function get overlapping actors for each component. It has array output. I counted Lentgh and stored that to variable of type Integer. Then I made array of all this variables and used function min of int array This prefered a free 0 overlapped chair whith with smallest index.

more ▼

answered Mar 21 '19 at 01:09 PM

avatar image

Salikhov
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