Making a reflector 'reflect' when light hits it

Hello,

I am one for details and right now I am brainstorming how I can make a retroreflective system using the material neon and plastic(or fabric, low light influence and reflectance), along with light (and raycasting?) So, here are the road reflectors unmodified with the Neon material:

The reflector(s) in their current state are ‘reflecting’, but shouldn’t be. I wonder if I could use Region3 (but that’d be a region for every reflector)

Wide shot:

Thanks for helping!

1 Like

@xray144 you could use distance checks within a LocalScript

--distance from the reflector (in studs)
local distance = (playerRootPos - reflectorPos).Magnitude

--the distance at which the reflector starts "reflecting" (in studs)
local reflectDistance = 50

--if distance from reflector is less than or equal to reflectDistance
if(distance <= reflectDistance) then
    --start reflecting
else
    --stop reflecting
end

2 Likes

What would a check to make sure the other side wasn’t reflecting? Say, you were traveling the correct direction on a road, you would see the white half of the reflector, going the wrong way you would see the red side.

that gets a bit more complicated but you can use your red/white parts separately for distance checks.

also depending on the red/white parts ORIENTATION you can use lookVector*reflectDistance, to determine what reflector will ‘reflect’ based on players Vector Direction and distance.

I cannot give you exact code because i don’t know the orientation of your parts.
but try combing the distance checks with Directional Vectors from your parts CFrame and your players HumanoidRootPart CFrame

here is possible directions you can use from a CFrame

cf.lookVector = forward direction
-cf.lookVector = backwards direction
cf.rightVector = right direction
-cf.rightVector = left direction
cf.upVector = up direction
-cf.upVector = down direction

So, back to the light, could I use raycasting from the headlight part to check if the light has ‘hit’ the reflector to make it brighter? I get the player checks, but it sounds like it would reflect regardless of a light source or not. Am I wrong?

Have you tried using a bloom effect? You change the threshold throughout the day; here is default everything with threshold at 0.5, with clocktime at 0, with a light with brightness 3 and the red part is smoothplastic. This would be a lot easier to put into your game and would likely have better performance.

that wouldn’t work for neon parts, but you could cast a few rays coming from the headlights and if the rays hit a reflector then you can change the reflector to NEON or add a light source to it.

a ray cast is basically just a projectile that flies from point A to pointB, if it hits something then you can detect it.

or you can use the actual ray object that roblox provides below

Bloom is a global setting for the lighting service, if it can be used for individual parts, I didn’t know.

yeah bloom is global for lighting, it wouldn’t really be efficient in your situation I don’t think.

I did have Bloom on for testing, but it wasn’t desired.

it is a global setting, however it can be configured such that a part will become “neon” when a bright enough light hits it, as long as the part is a brighter color. Using a script to sync the threshold to the time would make it be brighter at night and darker in the daytime.

I see, I will try to implement it.