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"

Need some help with OnPerceptionUpdated's sensed actors.

Hey, i'm working a bit with an AI for my game but i have gotten a bit stuck when it comes to the perception of actors for my AI.

I currently have three actors that are attached to the player character which are registered for sight stimuli and i want the AI to know how many of these three actors are in sight at all time. It looks something like this when the player is standing in view of the AI. alt text

But the issue i'm currently having is that i can't figure out how to get so that the AI knows how many of these are in view. The reason i cannot figure this out is because my OnPerceptionUpdated function's sensed actors sometimes does not register the three actors it seems. When i'm walking around in the view of the AI and walk behind certain things the sensed actors array show weird values, for example when i'm standing in full view the sensed actors array is showing that it has 1 value.

 PerceptionComp->OnPerceptionUpdated.AddDynamic(this, &AMurdererController::AISense);

 void AMurdererController::AISense(TArray<AActor*> SensedActors)
 {
     TempInt = SensedActors.Num(); (Printed out from Tick())
 }

Anyone have any idea how i can go about doing so that the AI knows how many of the three actors that are attached to the player is in view. How i want to do is that the AI should go through the sensed actors array and maybe check if it finds any of the three actors and that it was WasSuccessfullySensed().

Product Version: UE 4.8
Tags:
more ▼

asked Jul 28 '15 at 11:12 AM in C++ Programming

avatar image

Solicio
200 54 54 64

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

1 answer: sort voted first

It's a while since I played around with the perception component, but from what I remember, the array passed into the update event is not a list of actors currently sensed. I think it's a list of actors whose perception state has just changed. So I believe you need to maintain your own list of currently perceived actors by checking the last stimulus information for each actor passed into the update delegate, and marking them as perceived/not perceived based on whether the last stimulus was a successful sensing.

I know Mieszko intended to change how this worked however and I haven't kept up to date with it, so I'm not certain what the current situation is.

more ▼

answered Jul 28 '15 at 05:34 PM

avatar image

kamrann
2.1k 83 37 121

avatar image Solicio Jul 28 '15 at 06:20 PM

Ok, that is most likely the reason why the array num is sometimes off.

Correct me if i'm thinking incorrectly, but what you are suggesting is having my own array of actors that are currently successfully sensed? And that i would do this by adding/removing actors to this array in the OnPerceptionUpdated function dependent on if they were succesfully sensed or not?

avatar image kamrann Jul 28 '15 at 06:44 PM

That's right. I believe the perception component is designed to just give information on received stimuli. It's up to you to decide how you want to combine the stimuli from different senses, or over a period of time, to generate a higher level measure and memory of what your AI is aware of. Adding to/removing from an array as you outline would be the most basic approach to doing that.

avatar image Solicio Jul 28 '15 at 06:53 PM

Ok, thanks!

(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