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"

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: https://youtu.be/Yd_knjA0WrM?t=4m57s

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: http://prntscr.com/itf10n

What happens: http://prntscr.com/itf1rz

What it happens when I move: http://prntscr.com/itf26q

What I want: http://prntscr.com/itf33c

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

Product Version: UE 4.16
Tags:
more ▼

asked Mar 19 '18 at 06:38 PM in Blueprint Scripting

avatar image

Pataxu
28 4 7 14

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

1 answer: sort voted first

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.

alt text

capture.png (311.9 kB)
more ▼

answered Mar 19 '18 at 09:55 PM

avatar image

ThompsonN13
10.1k 33 10 25

avatar image Pataxu Mar 20 '18 at 02:08 PM

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)

avatar image ThompsonN13 Mar 20 '18 at 03:27 PM

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.

avatar image Pataxu Mar 20 '18 at 05:20 PM

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?

avatar image ThompsonN13 Mar 20 '18 at 07:58 PM

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

avatar image Pataxu Mar 21 '18 at 05:37 PM

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.

avatar image ThompsonN13 Mar 27 '18 at 09:30 PM

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.

avatar image Pataxu Mar 28 '18 at 05:36 PM

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

avatar image ThompsonN13 Mar 28 '18 at 09:53 PM

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.

avatar image Pataxu Mar 28 '18 at 10:29 PM

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.

avatar image ThompsonN13 Mar 28 '18 at 10:46 PM

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.

avatar image Pataxu Mar 29 '18 at 06:20 AM

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

avatar image Pataxu Mar 29 '18 at 07:03 AM

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

avatar image Pataxu Mar 30 '18 at 04:54 PM

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

avatar image ThompsonN13 Mar 30 '18 at 09:30 PM

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

avatar image Pataxu Mar 31 '18 at 10:36 AM

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

avatar image ThompsonN13 Mar 31 '18 at 02:00 PM

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.

avatar image Pataxu Mar 31 '18 at 03:07 PM

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

avatar image ThompsonN13 Mar 31 '18 at 03:25 PM

your print string isnt connected to anything so it wont work, it needs the exe pin (the white one) connected otherwise it wont ever be activated.

the variable picture doesnt tell me much other than that its a static mesh and its name. which is fine.

as for the collision you want to have it set to either project default or "simple and complex" for now. try using a box collision for now instead of the mesh. so we can eliminate a few variables before tackling if theres issues with the mesh.

not sure if itll help but heres a updated picture of the script i have and the collision settings of the sphere collision im currently using. ive modified the script to run once when the button is initially pressed as well so its easier to test with. i also added in the print string so you can see where to put it.

alt text

capture.png (423.6 kB)
avatar image Pataxu Mar 31 '18 at 05:05 PM

Ok, I guess is now working. I've replaced the cone with a box collision

Im playing with 2 screens, one is the Zorro (Main Player) and another is the Ghost. When I press G, there is a print that says 0 like in your message and that means that isn't working, but when the Ghost enter to the box collision radius it works and prints 1 and the loop works, but there isn't any tracer, so that means that is working and the cone was correctly working all the time, but tracers doesn't exist.

So, I tested again with a cone and it works, when the ghost is behind a wall and the cone is hitting it prints: 'nohit', so that means the blueprints worked. So... the problem was that I don't understand the system and I ever guessed that here's going to be a magic line when im pressing G and if that line hit the ghost the ghost losses life, and not a system that need to detect the ghost to do the tracer (Wich is a lot more effective and more game-optimizing). The line doesn't appear, but I guess the result is the same.

Thank you a lot, you're a good person, you helped me a lot, I've checked you 'correct awnser' early and you still replying me, the community needs more people like you. You are working on Epic Games or something?

http://prntscr.com/iyzca8

avatar image ThompsonN13 Mar 31 '18 at 06:45 PM

as long as the length of the array is greater than 0 then you should have the line trace happening its weird if its not.

the basics of the code is it first checks are there any actors i care about in range, if no then do nothing and the script ends, if there are actors in range then it goes on to the line trace which is basically asking ok can i see the actor from where i am, if no then not hit, if yes then target hit. well i should clarify a bit on this last part, its really asking is there anything blocking my vision to the target actor thats why the branch at the end can be a bit confusing.

in your third paragraph you mention the overlap for game optimization which isnt really the reason for it, i used the overlap to get a reference to the target actors. basically if you tried to only use a line trace how would you know where to set the end without already knowing the location of what your looking for. it is better for optimization in a way buts its also easier to get actors that are close. other people would jump straight to all actors of class but why get everyone in the level, just seems silly to me.

as for the last bit thank but no i dont work for epic im just a hobbyist i dont work in the games industry or even the computer industry haha. just glad i could help out. let me know if you end up needing more help on this one.

avatar image Pataxu Mar 29 '18 at 12:44 PM

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 fucking broken the code, so I will need to make it again. Thanks master, I will reply you soonest possible. :)

(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