# Flashlight with cone tracer

**URL:** <https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279>\
**Category:** Rendering\
**Tags:** unreal-engine, Lighting, Blueprint, question\
**Created:** [March 19, 2018, 6:38pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279 "2018-03-19T18:38:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 19, 2018, 6:38pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/1 "2018-03-19T18:38:57Z")

</div>

So, I want to make a system who if I keep pressed a key, the flaslight turn on and makes a tracer with a cone form for detect the player 2 and rest to it some life.

Well, something like this:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/f/f/fffe20fc558649273afb864ee1413543b3cfa843.jpeg "Nintendo Land: Luigi's Ghost Mansion (5 Players)") ](https://www.youtube.com/watch?v=Yd_knjA0WrM)

I don’t known if the method used on ‘Nintendo Land’ programming was adding a hit detector on the light, a multiple light model who reacts on the walls or tracers. (Yeah, im making a copy of Nintendo Land, for mobiles)

I only want to make this system, I tried with adding hitbox to a light 3d model but the light can pass tought the walls. And now I tried with tracers and I when I press the key all works fine, but it generates a trace and the trace is static and doesn’t move with the player, and I want when the key is holding-pressed that trace turns-on and follows the player. I don’t known if I explained correctly, so I will put some screenshots.

Blueprint:

> **[Screenshot](https://prnt.sc/itf10n)**
>
> Captured with Lightshot

What happens:

> **[Screenshot](https://prnt.sc/itf1rz)**
>
> Captured with Lightshot

What it happens when I move:

> **[Screenshot](https://prnt.sc/itf26q)**
>
> Captured with Lightshot

What I want:

> **[Screenshot](https://prnt.sc/itf33c)**
>
> Captured with Lightshot

Please, help! Im a very-new user on Unreal Engine (And I decided to make a simple game, but the lantern system is the hardest thing of this.)

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [March 19, 2018, 9:55pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/2 "2018-03-19T21:55:17Z")

</div>

to duplicate the functionality in the video of healing players in the cone of light i would use a cone shaped mesh to get actors then use a line trace to ensure that they are in visual contact (make sure they arent on the other side of a wall). then have all of this on a timer so that the script can happen many times.

in the picture below youll see how i implemented all of this. on input Q pressed begin a looping timer that fires the check for players event, when the input is released the timer stops. the check for players event get all the actors overlapping the cone mesh, of the type specified in the filter (optional). then it runs each through a for each loop which checks is the target is in visual range via the line trace. then i just added health to the target if it was of a certain type.

 ![234371-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/d/d1dd12a8fcaa6d4ffaa882a088ae32902c81caad.png)

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 20, 2018, 2:08pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/3 "2018-03-20T14:08:35Z")

</div>

Oh! Thank you! So, I have now a problem, is normal that the debug lines aren’t visible? Because now the trace lines doesn’t appear, and I’ve configured all like in your image, changed to my characters names and not much more.

I want the ‘damage ghost’ system on the video, not heal players, but is the same thing, only place a positive number instead of a negative when changing heal, so you BP is good.

Here’s my BP:  
[http://prntscr.com/itt01q](http://prntscr.com/itt01q)

Part 2 of BP:  
[http://prntscr.com/itt0pc](http://prntscr.com/itt0pc)

The main characer, who wears the flashlight is called ‘Zorro’, and the character what I want to hit with the light or tracer is called ‘Ghost’ and his life value is called ‘GhostLife’. The ‘flashlight’ named mesh is the cone, so that isn’t the error reaseon (Or probably yes)

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [March 20, 2018, 3:27pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/4 "2018-03-20T15:27:13Z")

</div>

as long as the event is firing and there is an actor of type zorro overlapping the flashlight you should be getting debug lines. thats probably your issue right there actually, the filter on your get overlapping actors should be set to ghost according to what you wrote above.

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 20, 2018, 5:20pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/5 "2018-03-20T17:20:09Z")

</div>

[http://prntscr.com/itwac5](http://prntscr.com/itwac5)  
Still doesn’t working, no debug lines. I haven’t configured the ghost spawn yet, so when I play there’s only the player with the flashlight who don’t trace the line, will that affect the code?

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [March 20, 2018, 7:58pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/6 "2018-03-20T19:58:47Z")

</div>

The line traces only happen when there is a target overlapping the cone. So if your looking for a ghost but theres no ghost overlapping then tou wont have a line trace. The trace is only there to make sure your not damaging enemies that are hidden behind a wall

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 21, 2018, 5:37pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/7 "2018-03-21T17:37:15Z")

</div>

Ok, I’ve added the ghost, I’ve run the game with 2 screens, 1 is the Zorro and another the Ghost, Flashlight still without working.

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [March 27, 2018, 9:30pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/8 "2018-03-27T21:30:54Z")

</div>

you need to elaborate more on whats not working. let us know what did and didnt happen and what changes youve made to your code. otherwise i have to try to guess at what youve done and the possible settings and things that could be setup wrong.

break down the situation/code into parts and learn what it does, how it functions. then debug step by step using print strings. dont just go by the line trace didnt make debug so it doesnt work and try something else. make sure the timer works, then make sure your getting overlap events, then move on and on until you reach the end.

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 28, 2018, 5:36pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/9 "2018-03-28T17:36:42Z")

</div>

Okay, thanks.

There is the actual blueprint maked again: [http://prntscr.com/ixnjsj](http://prntscr.com/ixnjsj)

So, It only prints when I press and realase G: [http://prntscr.com/ixni1u](http://prntscr.com/ixni1u)

Seems like the custom event doesn’t work. I have Unreal Engine 4.16, if that affects (I can0t use newer versions, 4.17 and superior crashes).

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [March 28, 2018, 9:53pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/10 "2018-03-28T21:53:20Z")

</div>

do you keep the button pressed for at least 1 sec so that the loop has time to run? the loop only run while the button is held.

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 28, 2018, 10:29pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/11 "2018-03-28T22:29:20Z")

</div>

Hahahahaha…hahahaha…HAHAHAHAHA, IT WORKED! 9 DAYS WORRIED ABOUT CANCELING MY GAME AND THE ERROR WAS BECAUSE I DON’T HOLD MY BUTTON WTF. Ok, tomorrow I will complete the blueprint and see if it works. I don’t known if it going to works, because sometimes i’ve tried to rage-keep pressed G and no tracers. But enjoy your ‘Accept awnser as correct’ by now, you really deserve it.

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [March 28, 2018, 10:46pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/12 "2018-03-28T22:46:46Z")

</div>

if you want it to activate when you first press the button to then just add in a sequence node before the timer and have one pin got to teh timer and the other pin bypass the timer and go directly to the script.

glad you got it working.

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 29, 2018, 6:20am UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/13 "2018-03-29T06:20:32Z")

</div>

Still didn’t working, and the reason is Looping doesn’t work:  
[http://prntscr.com/ixvc9t](http://prntscr.com/ixvc9t)  
[http://prntscr.com/ixvcxx](http://prntscr.com/ixvcxx)

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 29, 2018, 7:03am UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/14 "2018-03-29T07:03:46Z")

</div>

It just prints everything is before the loop, I don’t known if the issue is of ‘Get Overlapping actors’

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 29, 2018, 12:44pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/15 "2018-03-29T12:44:53Z")

</div>

Ok, thanks! I guess that is not working is the timer or the loop, because the old code doesn’t work if I add the timer. Let’s open Unreal Engine and see what happens, but I’ve been streesed and changed the code 1000 times with YT tutorials to see what happens and I’ve ■■■■■■■ broken the code, so I will need to make it again. Thanks master, I will reply you soonest possible. 🙂

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 30, 2018, 4:54pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/16 "2018-03-30T16:54:51Z")

</div>

Still not working, followed a lot of YT tutorials, the ‘ForEachLoop’ doesn’t work, I guess is because the ‘Get Overlapping actors’.

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [March 30, 2018, 9:30pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/17 "2018-03-30T21:30:22Z")

</div>

Does the mesh or volume your using for the overlap have generate overlap events on and have the proper collision settig auch as overlap pawn? If you eliminate the filter on the get overlapping actors does it work then? What the length of the array? As you can tell im teying to see if its the overlap thats failing. I remade this blueprint the oher day and it worked fine so its somewhere in your settings. Didnt you just have it working the other day too

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 31, 2018, 10:36am UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/18 "2018-03-31T10:36:07Z")

</div>

**’Does the mesh or volume your using for the overlap have generate overlap events on and have the proper collision settig auch as overlap pawn?'**

Yes, ‘Generate overlap events’ is enabled, and on the proper colission setting I’ve tried to set it to: ‘OverlapAll’ and isn’t working, and tried to set it to ‘OverlapOnlyPawn’ and still isn’t working

**’If you eliminate the filter on the get overlapping actors does it work then?'**

No

**’What the length of the array?'**

I don’t known what is a array

**’Didnt you just have it working the other day too’**

Yeah, I was singing victory early, because it was working before I’ve finished the blueprint and added the ‘ForEachLoop’.

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [March 31, 2018, 2:00pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/19 "2018-03-31T14:00:16Z")

</div>

an array is basically a list, usually a list a variables. if you look on the for each node on the input side you will see it says array on there and has a square made of 9 smaller squares (thats the symbol for an array in ue4).

now based on your previous blueprint that you posted a little while ago and you saying that everything before the loop works then it leads me to believe that the issue is with the overlaps. the first step here is to ensure that you are getting overlapping actors since this seems to be the most likely issue. to check if there are any actors being overlapped, from the overlapping actors node drag off the overlapping actors return array pin and the search for length. this will create a length node which you can then print its value using a print string. if this value is greater than 0 then you have your overlap setting properly setup (at least probably) if the length value is 0 then you are not getting any overlapping actors and the settings are messed up somewhere.

if there is an issue my guess is that it would lie with the mesh your using as a overlap volume. to test if thats the issue i would try replacing it with a box collision for testing purposes. one example of where this could be an issue is if the mesh didnt have simple collision then it wont create overlap events properly if i remember right at least.

---

<div class="post-metadata">

**Author:** ![eee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eee](https://forums.unrealengine.com/u/eee)\
**Post date:** [March 31, 2018, 3:07pm UTC](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279/20 "2018-03-31T15:07:30Z")

</div>

Doesn’t print string, here’s my blueprint: [http://prntscr.com/iyxwi1](http://prntscr.com/iyxwi1)

The cone is a static mesh, if it helps. And there’s a image of the variable: [http://prntscr.com/iyxxop](http://prntscr.com/iyxxop)

Mesh collision: [http://prntscr.com/iyxylb](http://prntscr.com/iyxylb)

Wow, my life are just problems xD

[Next page](https://forums.unrealengine.com/t/flashlight-with-cone-tracer/420279.md?page=2)
