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"

I'm attempting to get an actor to move to the closest actor of a certain class

View post on imgur.com

There's my logic, I'm not sure why it's not choosing an actor to move to.

Product Version: UE 4.10
more ▼

asked Nov 13 '15 at 08:18 AM in Blueprint Scripting

avatar image

8 6 5 8

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

1 answer: sort voted first

Hi Phillipjphry,

how about after "get all actor of class" you loop through the returned array, for each actor, get the distance between the pawn and the actor (location.pawn minus location.actor -> length), store that length as current shortest and store the index of that actor. Now the iteration continues, next actor, check if the distance is smaller, if yes, store the value as current shortest and the actor index as the target, if not, just move to next. After you have looped through the array, you have the distance and index of the closes actor. Not sure how often you plan on executing this and how many actor you have but it should work.

alt text

Regards, Damir

capture.png (223.7 kB)
more ▼

answered Nov 13 '15 at 09:06 AM

avatar image

Damir Porobic
211 12 8 20

avatar image Damir Porobic Nov 13 '15 at 09:11 AM

And I see that your "get AI Controller" is not connected to any execution pin, so this function won't be called.

avatar image Phillipjphry Nov 14 '15 at 07:29 AM

Yeah, that was me being disorganized.

avatar image Phillipjphry Nov 14 '15 at 07:31 AM

Thanks so much! And I made a small task afterwards with a passed actor reference to delete the actor moved to when the move was done. Now I just need to wrap my brain around your answer. I want to see if I can make it go to the furthest as well. Then everywhere inbetween.

(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