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"

Perception - Sight

I am trying to implement AI Perception - Sight into my game. The game is a type of tower defense, with enemy characters that walk on the ground towards a specified goal. I would like to make them see the towers then decide if it should fight or avoid.

However, I can't seem to get consistent responses from the perception component. I have 'AI Perception' component on my Enemy AI Controller, set it to Sight and have set the config to include all 3 "team" members, Neutral, Enemy, Friend (as mentioned by @mieszko). I have added the AI Perception Stimuli Source to the Super parent of my towers and set it to Sight.

alt text

I ensure the Stimuli Source is registered, both by Register Node as well as the default 'Auto Register' (and I have also attempted altering these to see if something would work.)

alt text

As far as I can tell, everything is setup like it should be. When I play and test everything out, some times it will see the tower(s) and sometimes it won't, which leads me to believe I have everything setup as it should be, because it will on occasion see the placement. I'll even set 3 of the same placement side by side and sometimes it sees some of them but ignores the others right next to it.

In the first 2 pictures you will notice that it sees different objects under the exact same conditions (nothing changed except a new game instance.) Worth noting that sometimes it won't see any of them.

alt text

And in this final image, you will notice that while it saw 3/4 of the objects, it broke sight after getting a little closer (denoted by the broken green lines that go from the object to behind the enemy.)

alt text

If it makes a difference, these assets aren't loaded into the game on start. They are placed in the world by the player.

Please let me know if I'm doing something wrong or if this is a possible bug? I'm not sure how/why it would be a bug unless it came in 4.10.1 because I've tried to do exactly like was done in the Training Twitch by Ian, Alexander and Mieszko where they added perception using I believe only 4.10.0. So I'm not sure if something possibly went wrong with the update. This project was created fresh in 4.10.1 and not migrated up from a previous version.

Thanks everyone/anyone!

Product Version: UE 4.10
Tags:
controller.png (330.7 kB)
placeable.png (219.0 kB)
playcombined.png (2.3 MB)
play3.png (1.8 MB)
more ▼

asked Jan 12 '16 at 04:23 AM in Bug Reports

avatar image

jtsmith
1.4k 70 29 92

avatar image Sean L ♦♦ STAFF Jan 12 '16 at 03:10 PM

Hello,

I have a few questions that could help identify the cause of the issue you are experiencing:

  • If you try placing the actors in the level manually before you start the game instead of placing them with your player, does the Perception register correctly?

  • I've seen cases where landscape collision blocks line-of-sight. Is it possible that this is occurring in your case?

avatar image jtsmith Jan 12 '16 at 08:17 PM

Thanks for the reply! Initially the landscape does block the direct line of sight as the NPC begins the level but as he draws nearer, line of sight is clear and should be able to pick it up/see it. If the collision is the issue that would mean that perception will only notice new things that entered the line of sight initially rather than at any point it has a clear view of it.

For your other suggestion I will get back to you later when I'm able to test that. I only tried placing persistent objects to test EQS, not perception.

Thanks again and I'll get back to you later!

avatar image jtsmith Jan 13 '16 at 03:31 AM

Hey Sean, so I tested this dropping in persistent obects into the world rather than placing them during the game. While it seems slightly more consistent in seeing the objects, it's still hit-or-miss. If I put 4 towers in side by side, like I did similar to the images above, it will notice some of them when they enter the sight radius and will occasionally see all of them but only when it is right next to them. I've tried varying the locations of both the objects as well as where I start the NPC but had similar results as mentioned above regardless of positioning. I then placed only 2 objects in the NPC's path (persistently not dynamically) and it noticed 1 of the objects and didn't notice the other till it was literally right next to the object, just before it passed it and out of its field of view.

My results during this round of testing were more consistent in the fact that I could predict which object it would see first and so forth; however, it is still inconsistent with regards to actually seeing the objects when they enter the line of sight.

Thanks again for you help!

avatar image Sean L ♦♦ STAFF Jan 13 '16 at 02:30 PM

Thanks for performing the additional tests and providing more information on your issue. I've attempted to reproduce the issue that you're having on our end, but I haven't been able to see the same behavior.

Have you been able to reproduce your issue in a clean project? If you are unable to do so, would you mind zipping up your project and providing a link to a Dropbox where I can download it?

avatar image jtsmith Jan 14 '16 at 03:01 AM

Thanks Sean. This, for the most part, is a relatively clean project and to reproduce this behavior in another project would still require most of the code I have in the game as of current.

I wouldn't mind sending you a zipped copy of the project via Dropbox but do you have an email I can send the link to so I don't have to make the download public?

Thanks again for the efforts!

avatar image Sean L ♦♦ STAFF Jan 14 '16 at 01:07 PM

You can PM me a link to the download through the forums. Here is the link to my profile: https://forums.unrealengine.com/member.php?160394-Sean-Flint

avatar image jtsmith Jan 15 '16 at 02:08 AM

Thanks Sean, I have sent you the PM with the download as well as the relevant information needed to help you figure out where everything is located.

avatar image Sean L ♦♦ STAFF Jan 15 '16 at 03:25 PM

I've spent some time looking into your project, and I'm not sure I'm understanding exactly what is supposed to be happening.

  • Your perception seems to be set up so the character can see the turrets, but I don't see you calling any OnPerceptionUpdated events anywhere, other than the unhooked ones in the Controller that you are using for testing purposes. Are you calling OnPerceptionUpdated somewhere else that I am missing?

  • Basically, I'd just like clarification on exactly which behavior you are expecting to see so that I can better understand what is going on. I see the turrets firing on the enemy without a problem, but I'm having trouble understanding exactly what the enemies are supposed to do when they see the turrets.

Thanks

avatar image jtsmith Jan 15 '16 at 07:32 PM

Hey Sean. I'm not doing anything with it right now because it's not seeing anything (or only part of everything.) I had the updated event hooked up to test but it spams the screen with the player pawn (which has always baffled me because it's not a registered stimuli source) which meant I had to dig through the output log feed.

To make my life easier I was just using the in editor debug feature to view the perception. Using that, and looking at the images above, you can easily tell what it sees and what it doesn't. The logic for what I want to do hasn't been implemented yet because it's not seeing everything. Ultimately I will want it to take everything in its sight radius, evaluate them (they won't always be the same tower) and decide which tower/target is its best chance for success. But again, I can't implement this until it actually sees everything in its sight radius.

avatar image Sean L ♦♦ STAFF Jan 15 '16 at 08:11 PM

It's possible that this could be something related to the debugger not displaying the proper information, which is why I was wondering if it would actually function as expected when you implemented it.

When you had it hooked up for debugging purposes, were you seeing results print out to the log that were consistent with what the debugger was showing you?

avatar image jtsmith Jan 16 '16 at 12:35 AM

Ya everything was consistent. The update perception only occurs when something changes in perception so if it would see the object, it would print it's name once and ignore what it couldn't see or failed to see. With the update perception hooked up, if I move an object that is attached to the cursor, before I place it, the update triggered consistently and constantly.

I also had the perception hooked up to tick to get all objects it sees and aside from continually spamming the player pawn, it would only print the name of the object it would see, consistent with the debugger in the editor.

avatar image Sean L ♦♦ STAFF Jan 18 '16 at 09:19 PM

Looking at your pictures again, have you tried increasing the Peripheral Vision Angle on your EnemyController_Ground's Perception component? It could be that the turrets that are not being detected are outside of that 90 degree arc that is set by default. Try making it something like 180 or even higher depending on what suits you.

avatar image jtsmith Jan 21 '16 at 02:34 AM

I did try this and result is the same. The PVA is actually calculated from both sides of the forward vector of the actor so a 90 degree PVA is 90 degrees to both sides, giving the actor a 180 degree field of view while a 180 PVA would give the actor a full 360 degrees of sight. The debug editor displays this with a green line (which should be different by default for clarity) that you can see in the images running perpendicular and through the actor in the sphere of its sight radius.

avatar image Sean L ♦♦ STAFF Jan 21 '16 at 07:39 PM

I've spent some more time looking into your project, and it's still a bit difficult to determine exactly what the issue is.

Do you notice that the debug "ball" (the one that should rest on a perceived actor), for lack of a better word, moves as you move the camera? It doesn't actually seem to attach to the perceived actor. Is this the same behavior you are experiencing?

Also, I upgraded the project to 4.11 Preview 3, and the perception seemed to be functioning properly. Although there were other errors that appeared as a result of the conversion, the perception was registering much more clearly. Give that a shot and see if you can get the same results.

avatar image jtsmith Jan 21 '16 at 07:50 PM

Ya I think it's quite odd that the perception registers the player pawn/camera since it has no stimuli source to it but I noticed this behavior when Ian Shadden does his perception in the AI live streams.

That concerns me that you received a bunch of errors when you updated to 4.11.P3 hopefully it's because P3 is only a preview. I would hate not being able to update the project to an expectedly feature rich update. I could make a backup copy of the project and attempt the perception in that. I will let you know how it goes.

Thanks again for your efforts

avatar image jtsmith Jan 29 '16 at 02:24 AM

Hey Sean, thanks for all your help with this, it is greatly appreciated! I tested @kamrann answer by moving the meshes pivot point up slightly from the landscape and everything is seen as it should be!

Thanks again for all your help, the community truly appreciates when Staff gets involved.

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

1 answer: sort voted first

The sight sense uses as a default GetActorLocation as the target point for tracing to check if an actor is visible. So one thing you should check is the pivot point of your mesh. If it's at the base of the mesh, then it may be coincident with or slightly below the landscape. Even on a perfectly flat landscape, floating point precision errors could mean that sometimes the trace will hit the landscape before hitting the mesh, which will result in a failed sight sense.

An easy way to see if this is the issue would be to replace your tower meshes with the default sphere mesh, and see if that fixes things.

more ▼

answered Jan 25 '16 at 06:34 PM

avatar image

kamrann
2.1k 83 36 120

avatar image jtsmith Jan 26 '16 at 07:49 PM

That is a very sensible answer! I'm going to give that a shot and let you know. If this is the case how would you suggest I handle placing the towers? Move the pivot up some then offset the mesh up that amount when placed?

avatar image kamrann Jan 27 '16 at 11:28 AM

Yeah I guess just adjust it in your 3D modelling program, or add an extra scene component into the blueprint to offset it.

Ideally the right approach is to override the method the perception system uses to determine if an object is visible. This way you can account for the object's size and other variables if you need to. There's an interface set up for this in the code, but as far as I'm aware it's not currently exposed to blueprints.

avatar image jtsmith Jan 29 '16 at 02:18 AM

This was absolutely the correct answer! I put each tower/object only 10cm up from the landscape and every object was seen when it should have been seen! I figured GetActorLocation used the pivot point but I didn't figure Perception used it. I assumed it would look for the bounds or collisions of the object using a trace.

I was able to get similar results, bypassing Perception using EQS, before you gave me the answer. Worked decently but if I'm not mistaken Perception is better to use than EQS for this? Although, now I'm going to combine Perception with EQS to get the desired behaviors I need but at least now my behavior tree doesn't need the extra EQS procedure to return it's "seen" actors and can run independently of each other.

Thanks again, you are awesome!

avatar image Ryan Darcey Jan 10 '18 at 04:47 AM

YAS! kamrann is exactly correct about overriding the method the perception system uses to check visibility by adding the IAISightTargetInterface to the actor that needs visibility checked and then override the only method for that interface: CanBeSeenFrom

(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