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: Moving to Targets / Giving items to Character?

Hi All

I have 2 questions, both I have got to work but there must be a simpler way.

Game Basics:

Type: Top Down

Event: NPC goes to one location, triggers overlap & collects items, goes to character, triggers overlap and transfers items to Character.

Locations: Possible up to 20 when game complete.

Moving to Targets: At this stage I have setup 3 buildings, 1 Wood, 2 Metal & 1 Bank. The character can walk up to the Wood & Metal buildings, click on them and the items get transferred to the character.

What I have setup on top of that is now to get AI Pawns to go to the Wood & Metal buildings, collect it & deliver it to me. Now this works, but it is very messy and by the time I finish, my blueprint will look a little like someone dropped spaghetti on the floor.

To go to the buildings, I put a Target at the front door, put a 'TAG' on it. Then inside the character, did a loop for each and looked for the TAG.But the loop never seemed to find the TAG, and this seems overkill for one Target, but wanted to do this in case I moved the building. At this point I am using 'Simple Move To Location' and manually entering the location.

alt text

alt text

Is there an easier way to do this?

Giving Items to Character: I have place a Collision around the character, when AI Pawn overlaps, I Cast to Each AI until it finds the correct one, each being fired on 'Cast Failed' alt text

Now if I have 20 different buildings & items, this would be very hard to amend or debug. Is there anything like a 'BP interface' that I could use instead of all this casting?

With Regards Narghile

Product Version: UE 4.20
Tags:
more ▼

asked Jan 03 '19 at 01:59 PM in Blueprint Scripting

avatar image

Narghile
1.7k 73 38 107

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Indeed there is such a thing as the Blueprint Interface, and it could certainly help you clean up the graph in your last screenshot a lot.

Alternately, depending on how you've designed your project, you could have each of the different NPC types derive from the same, common 'parent' class, and put the common behavior you're trying to access on that top-most 'parent' NPC class. Then, in that case, no matter which kind of NPC triggers the overlap, you can rely on being able to cast it to the common 'parent' class, because each individual type derives from it.

Now, as for programming the NPCs to go to various destinations in a clean and organized way, I suggest you look into UE4's Behavior Tree system. The official quick-start guide for Behavior Trees may be especially useful to you. It may not seem "easier" than the method you're using now, but it's surely the more robust and future-proof way for you to get your NPC AI working satisfactorily.

Hope this helps!

more ▼

answered Jan 03 '19 at 05:24 PM

avatar image

the_batch
1.1k 4 5 8

(comments are locked)
10|2000 characters needed characters left
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