How to create a raycast permanent/constant?

Hi my name is divine and I’m a noob in both programming and blueprints. And I’m starting to like blueprints.
Well I want to create a detection system in blueprint using raycast to interact with objects. I want it where in if the object interaction is true then there’s shows a detection message (“open”, “pick” , “use” , “press E” , “etc”). Well the interaction system with the helpful message is easy with the box trigger (like the epic tutorials) but I want the detection to be pin point so if I have stack pile of objects in front of me then I can only trigger that single object that I want without triggering the objects beside it. So I tried to create a ray cast and its workin pretty fine. Well as I observed what raycast is doing is its firing rays rapidly. So when I tried to use ray cast to toggle visibility of the “detection message” it toggles on and off so frikin fast and the message was already flickering. Same with other objects, lights etc. Is there a way that I can only cast a single ray that is constant or permanent?

I havent tried yet but, I was actually thinking to fake this by putting a long straight mesh pointing in front of the camera like the raycast to simulate detection system. but I’m not really sure if this is goin to be efficient since I’m still goin to deal with a lot of trigger boxes. like 1 trigger box is to one interactive item.

Line Trace is what you are looking for.

thanks for the response, thats the same line trace I use. And as Ive said on my post its firing rapid rays that if I use that to toggle visibility or detection its goin to toggle on and off so fast. Frikin fast! xD

Ahh, sorry. I should have read the whole thing. :stuck_out_tongue:

Use a DoOnce function after your key input then, and dont forget to Reset it with Input Released. This will let you send a single trace every time you press the key.

If this still doesnt fix your problem post a screenshot of your raycast BP please.

I’ll check, hmm as I said I’m not a pro yet with blue prints so I’m gonna read that DoOnce function and how I can use that to set a detection system using raycast.

because I still want to have that raycast running all the time so it can always check for interactive objects.

Hi there I already did try the doOnce function. But I got some problems and confusion about it. So before the problem is that I toggle the visibility of the message on and off so fast. Now I use the doOnce function and It did work and toggle once even if the ray is still firing.

but it stays on forever and I cant toggle it off again.

Now you mentioned about the Input Released and reset. would that solve this problem? and how? I’m actually trying to do the Reset thing on that node on the custom event. hehe xD

Toggling the visibility is why its flashing, every frame it toggles on, next frame toggles off and so on.
100FPS = 50 on 50 off.

Instead of doing Toggle Visibility, SET visibility will solve the problem.

However you will need something to Unset visibility. personally, i use a trace to set a boolean to true on the object, which then sets a counter for fade out time. that way when you are not looking at the item it will manage its own visibility.

the alternative is storing a reference to the object you are tracing to, set visibility ON, if trace actor result != to previous result, cast to previous object reference set visibilty false

Two options, hopefully one will work for you.

Ahh, I see. I’m still learning blueprints(and I’m also still learning programming) but in a programming perception I think I can try the first method you mentioned with the boolean (and if I’m not wrong its the branch node?). I just dont know what specific nodes to use. I’ll try to do research on this ;D

Thats right, feed your Boolean variable into the branch node - whatever the state of the variable is, it will follow the resulting nodes.

i control it with the boolean to reset the hide timer back to 1 second and run it every tick, and every tick i subtract the delta time from the float. if float =<0 then set visibility = false. theres a little more to it, but i dont have access to my implementation to screenshot it at the moment.

If you have many object types to add this to, perhaps adding it to a blueprint component is a better choice(but then you need to cast to blueprint component class instead) then all you need to do to make the object toggleable is to add the component to the blueprint object.

again - there are probably better ways of doing this - i’m also a beginner.

thanks to MrGrr, well Ive already solve the problem about the flashing because of the toggle node by using set visibility. but I’m still confuse on how the reset works. So once I set visibility it will stay visible all the time. FOREVER!!!

Now I’m not sure If this is the right way to do this but what I did is that I set an EventTick with new visibility unchecked.
So basically everyframe the visibility is not set and it will only set whenever the ray is hitting the actor.

Again I’m not sure if this is the most efficient way to do this but its already workin for me at the moment. Now I got a new problem about enabling and disabling the player input so I can press a key like “F” to toggle the light on and off. but I think I’ll post it as a new question. xD