Flashlight with cone tracer

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:

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:

What happens:

What it happens when I move:

What I want:

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.)

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.

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

Part 2 of BP:
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)

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.

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?

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

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.

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.

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. :slight_smile:

Okay, thanks.

There is the actual blueprint maked again: http://prntscr.com/ixnjsj

So, It only prints when I press and realase G: 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).

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.

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.

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.

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

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

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

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

’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’.

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.

Doesn’t print string, here’s my blueprint: 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

Mesh collision: http://prntscr.com/iyxylb

Wow, my life are just problems xD