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"

Cone Check/Cone Trace

EDIT: As I found a solution to my first question, I'm changing the question to just focus on my other question.

I'm looking for a way to reliably do traces in a cone from an object. In my project I'm using a Behavior Tree, and as the Cone Check decorator comes with it, I was wondering how it works. I can't get it to function properly, even as I have created a debug cone to help me out with the matter. As there is no way to properly debug it, I have no idea how to make it work properly with trace blueprints.

My question is: Is there any way of having some reliable cone tracing in UE4? Cone Check has been working sporadically, but I'd like to know if there was some way of just having a Cone Trace?

Product Version: Not Selected
more ▼

asked Nov 02 '14 at 12:31 PM in Blueprint Scripting

avatar image

420 32 9 27

avatar image Sentura Nov 02 '14 at 12:32 PM
avatar image eXi Nov 02 '14 at 12:41 PM

Just a question, because maybe i get wrong what you want.

A cone trace, for example, would be the view field of a character?

And you have come up with a solution for this trace but it doesn't rotate with the player/object? So it updates the position but not the rotation?

Isn't there an easy way to just get the rotation of the object and apply it to your cone trace thing?

avatar image Sentura Nov 02 '14 at 01:02 PM

Exactly a view field.

Getting the rotation and applying it doesn't work as I have already described.

avatar image Sentura Nov 02 '14 at 05:35 PM

Bumping this in hopes that someone has an answer. I'm stuck on this.

avatar image Adam Davis STAFF Nov 03 '14 at 08:14 PM

Hi Sentura,

Please do not bump threads that have not gone unanswered for at least four days, this clutters the answerhub and makes it very difficult to parse through and help anyone. Thank you.

avatar image Sentura Nov 04 '14 at 01:11 AM

I apologize.

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

3 answers: sort voted first

Hey there, I just created this tutorial and the first thing I do is create a cone check for the AI. It uses simple maths and you can just loop through all the characters you want to find out which are inside the cone.

Hope it helps!


more ▼

answered Jun 08 '15 at 04:21 PM

avatar image

Asher S Einhorn
650 94 80 181

avatar image Sentura Feb 15 '16 at 02:53 PM

Thanks for posting this. A programmer friend of mine basically made the same solution, and I completely forgot that I had asked it here. Your tutorial should point others who were wondering about this in the right direction!

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


this is just something i came up with in a few minutes.

I used a for loop to make 5 Single Sphere Traces and used some math to position them each a bit further away from the character and also to make them bigger. I added a short distance between the start and endpoint, because otherwise it didn't want to detect colisions.

I guess there is a better solution, but maybe this gives you an idea on how to do it.

vision cone

And the Blueprint:



If you have questions or if you want to discuss this method, feel free to ask me.

If you plan to make a bigger discussion about this topic, please stick to your forum post.

more ▼

answered Nov 03 '14 at 10:41 PM

avatar image

6.8k 333 185 468

avatar image Sentura Nov 04 '14 at 01:10 AM

That looks like a really good compromise!

Would the performance be in any way a problem here?

avatar image eXi Nov 04 '14 at 07:08 AM

I don't think this will hurt the performance, since you are told to use the shaped trace for a vision cone in the documentation. But i think it can be done better as i did. I just tried to make a fast simple example for you. You just need to fill the cone you have in mind with some simple shapes like the sphere or the box. I thibk i will try the box later the day after work to fill the gap between the eye and the ground directly in front of the player. Maybe the box has some more usefull settings.

I guess you could set the start point above the eye height and the end point beneath. Then you just subtract the radius to get each spherer on the same height.

avatar image Sentura Nov 04 '14 at 12:46 PM

I think the way you did it is honestly the most "natural" way. If the eyes look slightly down (as they would in real life), this would also taper the vision towards the end of the sight range.

I think boxes could be cheaper than spheres potentially, if only through the use of simpler geometric shapes. Incidentally they might also fill in the small "gaps" between spheres where the pawn in question would not be permitted vision. I'm going to set up the sphere version later for testing.

avatar image eXi Nov 04 '14 at 12:58 PM

To fill the gaps you only need to choose some factor better than me. :D

The thing is, it's up to you if the NPC should see people in front of them, even if they crouch under their eyes, or if they should only recognize them, if they see them like the way i did above.

Most of the times (if i look at actual games) the NPC sees you as soon as you run into his view cone. So for this it would be better if you move the first 2 or 3 spheres from top to bottom, so that you can't crouch directly in front of the NPC without getting noticed.

I don't know if you can make the box something differ from a³. So that you make it a a b and b is the height, so it would always be as heigh as a character.

If you are pleased with my answer, feel free to accept it by pressing the check mark at the left side. (:

avatar image Sentura Nov 04 '14 at 01:05 PM


I think the way the spheres work right now, even in a crouching position they'll be able to see you. That being said, my responsibility in this is just to provide a rough AI - to which end this "cone" will suffice.

Thanks for your time, and feel free to respond with the cube version here as well! =)

avatar image Sentura Nov 04 '14 at 02:38 PM

I'm actually running into a problem here as the enemy's vision seems to never be limited to just the cone. Instead, it seems to be able to see me anywhere, even if I am not inside the "cone" of vision. What's wrong?

Just to clarify, my setup is the same as yours blueprint wise, while I'm using a third person setup instead.

avatar image eXi Nov 04 '14 at 04:45 PM

The thing is, you need to specify what the trace actualy traces. I set it to "visibility" so it will also trace the ground for example. You need to use custom channels for your character and only trace them. You can also make an object trace instead of a channel trace and specify the object ("Pawn" for example).

So at them moment, this setup traces everything visible and will only ignore the air. I made it to get the cone shape. You need to adjust it for your game.

avatar image Sentura Nov 05 '14 at 10:22 PM

Well I used "camera" as the channel. I don't know what the difference is though, it seems both of them will look through any obstacles. I don't know how to make it so they would work only in their vision radius. Camera previously worked when I used a two step trace (large multi sphere + single trace camera vision).

There's also no documentation on this exact point so I'm at a loss.

avatar image eXi Nov 05 '14 at 10:37 PM

You just need to specify what the trace should look for. I normaly use the Trace by Object instead of Channel. I create an Objecttype in the Projectsettings for the Object i want to get traced and set the object collision settings to block this Type. Now i set the Tracefunction to also to the Object Type. You can test this with "Pawn" or something. Now the Trace should only recognize the Pawn or Player or what every you want to track. The name of the type can be anything but should be named well suited like a variable in coding :D

avatar image Sentura Nov 05 '14 at 10:40 PM

In this case I would probably have to use both though, at a huge performance cost as the cone is large enough to be able to see through walls -- if I pick object. That is why it would be better to pick camera that in my previous attempts blocked vision in terms of BSP, but does not seem to do so when it is based on the sphere-cone...

avatar image eXi Nov 05 '14 at 11:01 PM

Ah you are right, this could still look throught walls. What if you do a line trace from the NPC to the found object by camera to make sure there is nothing in between? So for example you have an NPC and your Player. You let the NPC find the player with this Sphere Cone Trace. Now, after you found him, you get his position, and trace from the NPC to the Player with a single line trace (shouldnt be a high performance cost) and check if there is a wall in between.

That sounds good in my head xD

avatar image Sentura Nov 05 '14 at 11:05 PM

That's what I have been doing, but that is so expensive performance wise that it lags up play in the editor - and that's just for a single pawn.

avatar image eXi Nov 05 '14 at 11:08 PM

That shouldn't lag at all. In my game i do line traces every tick and it's still not lagging. You should only do one single Line Trace if the Cone Trace found something. This shouldn't lagg at all. Is the cone trace itself taking too much performance?

avatar image Sentura Nov 05 '14 at 11:21 PM

It's a nested loop for each cone trace, so yes I assume it's the cone trace taking the bulk performance.

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

I'm starting in visual scripting but I think what I did is not bad (tell me if it is). I trace a square rotated 45° with a start and an end at the same distance. Then I check the closest actor in the square with a maximum distance from the player character, to respect a cone shape (a square cut in half). The prob is I can only have a cone with fov 90°.

Here is my fonction if it can help :

(yes, start and end are the same, there are two same pieces of script, to adjust if needed) alt text

more ▼

answered May 24 '18 at 10:52 AM

avatar image

1 1 3

(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