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"

How to implement a visible cone of vision?

Hey, I want to implement a cone of vision for my AI guards that the player can see in game.I don't know how I'd go about implementing something like this whether it be in code or Blueprint. I was thinking something similar to how Volume does it here.

alt text alt text

Product Version: Not Selected
Tags:
capture.png (310.8 kB)
capture.png (410.7 kB)
more ▼

asked Mar 09 '15 at 05:35 PM in C++ Programming

avatar image

DavidJCC
6 2 3 3

avatar image Stormrage256 Sep 18 '15 at 11:44 AM

Any idea if this can be done using some shader script?

avatar image State128 Feb 28 '16 at 02:57 PM

Hi Stormrage256, did you find a solution for making a vision cone that got blocked by static objects? (as in the video above)

avatar image Stormrage256 Mar 30 '16 at 04:45 AM

Yes, I've released it as part of the Top Down Stealth Toolkit. It's using custom meshes with line traces to detect objects in front of the player. The method is quite expensive, especially when you have lot of these present on the screen at the same time. But I've found out a few hacks to actually increase the performance like cancelling the line trace calculations when off screen, or when not close to any obstacles.

avatar image State128 Apr 04 '16 at 07:28 AM

So i supose that you use one mesh for each degrees then? Oki, would be nice to do it someother way. I've been thinking about using som sort of masked Material instance. Maybe will look into it later. Cheers

avatar image Stormrage256 Apr 04 '16 at 07:37 AM

When I was first researching on this topic, I came across an asset in the Unity Marketplace that seems capable of making dynamic vision arcs much better with a GPU based approach. You can check it out here: GPU Line of Sight

From what I've seen so far, it seems to be one of the best implementations out there. Maybe it would help you out in your venture.

avatar image State128 Apr 05 '16 at 06:15 AM

Thanks, I'll check it out!

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

1 answer: sort voted first

I did something similar, both with a visual cone and without. They are two separate objects.

First, the visual cone is pretty easy. Just create a static mesh and give it a translucent material, attach it as a static mesh component to a socket off of the head. Then you can toggle the visibility through blueprint.

Second is a bit more complex. I did it in blueprint for when an AI is in my flashlight's range. It could be carried over to an AI's sight though (I'm actually about to do that. I'm making sheep AI!). So if you can get the location of the target (the player) and the location where the sight is being emitted (AI eye Socket). Subtract one from the other and normalize it to get the direction of the sight location to the player.

Separately, get the world rotation from the sight location. Get the forward vector of that.

Then get the Dot Product of the forward vector and the direction to player. Compare that to a # to get the angle of your cone. I did mine at .75 If the target (player) is in the cone, then it returns true. If they're out, then it returns false. You'll probably need to put a distance cap on it too to match up with your visual.

Here's a pic of how I did mine to match the description above. alt text

more ▼

answered Oct 02 '15 at 09:40 PM

avatar image

CharlieTheTall
201 14 26 41

(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