# Cone Trace

**URL:** <https://forums.unrealengine.com/t/cone-trace/14459>\
**Category:** Blueprint\
**Tags:** unreal-engine\
**Created:** [November 1, 2014, 10:05pm UTC](https://forums.unrealengine.com/t/cone-trace/14459 "2014-11-01T22:05:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 1, 2014, 10:05pm UTC](https://forums.unrealengine.com/t/cone-trace/14459/1 "2014-11-01T22:05:12Z")

</div>

So I’ve searched the forum and I can’t come up with any worthwhile answers.

Why isn’t there a cone trace component in blueprint? I mean it would seem obvious to do something like this. For now the best thing available is to attempt to fake it through multiple single rotating box traces in order to get things working. Definitely not cheap performance wise, takes a lot of time to set up properly and creates a lot of visual clutter.

For cross reference, UE4 Answerhub question: [https://answers.unrealengine.com/questions/127128/cone-checkcone-trace.html](https://answers.unrealengine.com/questions/127128/cone-checkcone-trace.html)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_64c55f0b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_64c55f0b](https://forums.unrealengine.com/u/anonymous_user_64c55f0b)\
**Post date:** [November 1, 2014, 10:49pm UTC](https://forums.unrealengine.com/t/cone-trace/14459/2 "2014-11-01T22:49:57Z")

</div>

I’m not sure that’s the best thing available.

Why not try a box or sphere trace that contains the desired cone, and then determine the angle from the center of the cone to the object to determine if the object is within the cone or not?

Or even a cone-shaped mesh that you use purely for collision and disable when not in use?

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 2, 2014, 12:45am UTC](https://forums.unrealengine.com/t/cone-trace/14459/3 "2014-11-02T00:45:44Z")

</div>

Hm. So my previous post got deleted (I assume).

Why would it not be a good thing to have a cone shaped trace? It doesn’t make sense not to have one, as the performance hit would arguably be minimal. It would also add to the readability of blueprints as you’d need less nodes to just mimic similar behavior. Even a trapezoid shape would suffice, and that’s just a cube with its points adjusted accordingly.

I also just found out that there is the additional challenge of binding the rotation of the trace to the forward axis of the object projecting it. Is there any way of doing this?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_64c55f0b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_64c55f0b](https://forums.unrealengine.com/u/anonymous_user_64c55f0b)\
**Post date:** [November 2, 2014, 1:44am UTC](https://forums.unrealengine.com/t/cone-trace/14459/4 "2014-11-02T01:44:33Z")

</div>

I didn’t see another post.

I think a cone-shaped trace would be great, there are lots of games that would benefit from using conic shapes. But there isn’t one right now, so you’ll have to make something yourself:  
Difficulty to implement/Accuracy/Estimated runtime cost  
Hard/High/Cheap - Write the collision math from scratch or find an existing implementation that’s easy to port.  
Medium/Medium to Low/Cheap to Medium - Use an existing trace, and then determine the angle between the object and the center of the cone.  
Low/Low to Medium/Cheap to Medium - Use several line traces, more needed the wider the end of the trace is and the smaller the object you’re looking for is.  
Easy/High/Expensive - Activate a conic mesh as needed.

I’m sure there are some more solutions but those are all I can think of.

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 2, 2014, 1:58am UTC](https://forums.unrealengine.com/t/cone-trace/14459/5 "2014-11-02T01:58:31Z")

</div>

The problem with the traces is the problem I hinted at in my previous post: Trace shapes (or lines) won’t rotate with the object, meaning they will always face the direction they were put in. I have yet to remedy this problem, but it essentially nullifies all solutions containing trace nodes. What’s left is to hardcode it myself, a task I’m not going to attempt.

EDIT: For reference, this is the closest I found to someone figuring out a solution to the rotation problem, although it’s a solution that for various reasons won’t work for me: [Do a line trace in character facing direction (Blueprint Sidescroller)? - Blueprint - Unreal Engine Forums](https://answers.unrealengine.com/questions/11969/do-a-line-trace-in-character-facing-direction-blue.html)

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 2, 2014, 2:24am UTC](https://forums.unrealengine.com/t/cone-trace/14459/6 "2014-11-02T02:24:14Z")

</div>

Alternative, if there would be some way of using the cone check option from the behavior tree (as my setup currently is using BTs), that would be great. There is however very little information about this, and no way to debug it. My attempts with it have been futile due to insufficient documentation.

---

<div class="post-metadata">

**Author:** ![RhythmScript](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RhythmScript](https://forums.unrealengine.com/u/RhythmScript)\
**Post date:** [November 2, 2014, 3:58am UTC](https://forums.unrealengine.com/t/cone-trace/14459/7 "2014-11-02T03:58:38Z")

</div>

Traces can easily be set up to rotate with the object, by using the forward vector, multiplied by a constant, and added to the position vector, to determjne the end point of the trace.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_64c55f0b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_64c55f0b](https://forums.unrealengine.com/u/anonymous_user_64c55f0b)\
**Post date:** [November 2, 2014, 9:43am UTC](https://forums.unrealengine.com/t/cone-trace/14459/8 "2014-11-02T09:43:33Z")

</div>

> [@;](#):
>
> The problem with the traces is the problem I hinted at in my previous post: Trace shapes (or lines) won’t rotate with the object, meaning they will always face the direction they were put in. I have yet to remedy this problem, but it essentially nullifies all solutions containing trace nodes. What’s left is to hardcode it myself, a task I’m not going to attempt.

Getting the forward vector of your actor and multiplying it by the intended range should handle that just fine…

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 2, 2014, 9:53am UTC](https://forums.unrealengine.com/t/cone-trace/14459/9 "2014-11-02T09:53:16Z")

</div>

> [@Veovis Muad'dib;173308](#):
>
> Getting the forward vector of your actor and multiplying it by the intended range should handle that just fine…

It doesn’t. See the answer hub post I referred to.

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 2, 2014, 11:21am UTC](https://forums.unrealengine.com/t/cone-trace/14459/10 "2014-11-02T11:21:36Z")

</div>

So my findings in this: I got the cone check working in a static location, however I’m facing the same problem as before: The cone will not rotate with the object. I would very much like to know what I need to do to make it rotate, save for messing with the mesh and adding a socket just so it will work.

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 2, 2014, 11:23am UTC](https://forums.unrealengine.com/t/cone-trace/14459/11 "2014-11-02T11:23:08Z")

</div>

> [@RhythmScript;173239](#):
>
> Traces can easily be set up to rotate with the object, by using the forward vector, multiplied by a constant, and added to the position vector, to determjne the end point of the trace.

Just to make myself clear: This is what I have done so far. It will move with the object, but it won’t rotate for anything in the world.

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 2, 2014, 12:34pm UTC](https://forums.unrealengine.com/t/cone-trace/14459/12 "2014-11-02T12:34:33Z")

</div>

For cross reference, UE4 Answerhub question: [https://answers.unrealengine.com/questions/127128/cone-checkcone-trace.html](https://answers.unrealengine.com/questions/127128/cone-checkcone-trace.html)

---

<div class="post-metadata">

**Author:** ![DieByZer0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DieByZer0](https://forums.unrealengine.com/u/DieByZer0)\
**Post date:** [November 2, 2014, 2:05pm UTC](https://forums.unrealengine.com/t/cone-trace/14459/13 "2014-11-02T14:05:07Z")

</div>

I believe that a lot of people will end up going through a lot of trouble just to get this thing working.

I will bump this as I feel and correct me if i’m wrong this would help tracing of weapons such as shotguns yes?

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 2, 2014, 2:21pm UTC](https://forums.unrealengine.com/t/cone-trace/14459/14 "2014-11-02T14:21:22Z")

</div>

Shotguns, LoS, cameras, potentially view culling. It has a lot of uses.

---

<div class="post-metadata">

**Author:** ![Fen](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fen/32/635651_2.png) [@Fen](https://forums.unrealengine.com/u/Fen)\
**Post date:** [November 2, 2014, 5:21pm UTC](https://forums.unrealengine.com/t/cone-trace/14459/15 "2014-11-02T17:21:30Z")

</div>

Hello,  
what about shapetraces : [https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/index.html#shapetraces](https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/index.html#shapetraces) ?

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 2, 2014, 5:33pm UTC](https://forums.unrealengine.com/t/cone-trace/14459/16 "2014-11-02T17:33:59Z")

</div>

See my above posts.

---

<div class="post-metadata">

**Author:** ![RhythmScript](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RhythmScript](https://forums.unrealengine.com/u/RhythmScript)\
**Post date:** [November 2, 2014, 6:37pm UTC](https://forums.unrealengine.com/t/cone-trace/14459/17 "2014-11-02T18:37:57Z")

</div>

> [@;173311](#):
>
> It doesn’t. See the answer hub post I referred to.

This must be a quirk of 2D then because I can and DO use it for my 3D game all the time.

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [November 2, 2014, 6:58pm UTC](https://forums.unrealengine.com/t/cone-trace/14459/18 "2014-11-02T18:58:51Z")

</div>

I’m using 3D, can you post an example of your (working) blueprints? I’d love to do a check and see if it works.

---

<div class="post-metadata">

**Author:** ![Doug\_Richardson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Doug\_Richardson](https://forums.unrealengine.com/u/Doug_Richardson)\
**Post date:** [May 31, 2019, 12:14am UTC](https://forums.unrealengine.com/t/cone-trace/14459/19 "2019-05-31T00:14:53Z")

</div>

Going necro on this thread…

> [@](#):
>
> Hm. So my previous post got deleted (I assume).
> 
> Why would it not be a good thing to have a cone shaped trace? It doesn’t make sense not to have one, as the performance hit would arguably be minimal.

It would be useful, especially to implement realistic visibility calculations. My guess (I’m not physics engine expert, so definitely just a guess) is that it wouldn’t be a minimal performance hit.

PhysX [supports raycasts and sweeps](https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/GeometryQueries.html):

> [@](#):
>
> This chapter describes how to use PhysX’ collision functionality with individual geometry objects. There are four main kinds of geometry queries:
> 
> - raycasts (“raycast queries”) test a ray against a geometry object.
> - sweeps (“sweep queries”) move one geometry object along a line to find the first point of intersection with another geometry object.
> 
> …
> 
> A sweep query traces one geometry object through space to find the impact point on a second geometry object, and reports information concerning the impact point if one is found. PhysX only supports sweep queries where the first geometry object (the one that is traced through space) is a sphere, box, capsule or convex geometry. The second geometry object may be of any type.

UE4 calls both of these Traces, but one is tracing a ray and the other is sweeping a volume through space.

To try to implement a cone trace with one of these methods, you’d either have to a) shoot a N rays in a cone pattern to approximate it or b) sweep a bunch of objects (spheres or boxes probably).

Both methods suffer from the following problems:

1. They have variable resolution along the sweeps. At the beginning of the trace/sweep when the rays/objects are near each other, they are good at detecting hits, but as they move along the cone height, they get spread out and may miss hits that fall in the cone. The worst resolution is at the end of the cone, which is a function of the cone’s radius.
2. They require N traces/sweeps, depending on how much resolution you want. Since you lose resolution as the cone radius increases, you may also want to do more sweeps to compensate, which means users of this function would have to make a choice between performance and resolution.

I don’t know enough about the math behind traces and sweep hit detection to comment intelligently, but I think a cone trace, if possible at all, would require something completely different than they are doing now. For example, to implement a cone trace for visibility calculations like I want with a sweep, the physics engine would have to sweep something like a disc, increasing the size as it moves along.

---

<div class="post-metadata">

**Author:** ![6r0m](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/6r0m/32/1194563_2.png) [@6r0m](https://forums.unrealengine.com/u/6r0m)\
**Post date:** [January 9, 2020, 7:19am UTC](https://forums.unrealengine.com/t/cone-trace/14459/20 "2020-01-09T07:19:24Z")

</div>

any news/suggestions about this?

I want to make analog of the HUD GetActorsInSelectionRectangle for VR, I think that I need some trapezoid trace for this

[Next page](https://forums.unrealengine.com/t/cone-trace/14459.md?page=2)
