How to make my flashlight illuminate correctly even on straight lines? (aka a hallway)

Hi developers,

I’m having a very annoying problem that I think many other of you guys already have this problem, but the problem is that the flashlight don’t illuminate correctly a on straight line (aka a hallway). The thing that i mean it is those 2 screenshots (it’s lightning technology is set by future btw):

The one of the hallway:

The one of the wall:

As you can see, you can barely see the one on the hallway, how can i make it to show like in the one of the wall?

Any help would be appreciated :slight_smile:

2 Likes

one way to fix this is by making the flashlight a point light that moves to the mouse hit location, theres no way to currently increase the range of lights sadly.

If you need to make the light range smaller or larger or with variable brightness you need to code it yourself

3 Likes

uhh, great, how in the world am i’m gonna do that?

2 Likes

by increasing the range and lowering brightness depending on distance

for example:

local maxDist = 90 -- at this point the light is at minimum brightness and at largest range
local minBrightness = .1
local maxBrightness = 1

local maxRange = 60

local function brightnessChange ()

local distance = (mouse.Hit.Position - Camera.CFrame.Position).Magnitude

pointlight.Range = math.clamp((maxRange/maxDist)*distance, 0, maxRange) -- changes the range variably depending on distance where maxDist is when the max range is hit
pointlight.Brightness = math.clamp((maxBrightness*maxDist)/distance, minBrightness, maxBrightness) -- does the opposite of light range

end

math.clamp sets the numbers between the minimum number and the maximum btw (if its over the max, it becomes the max, if it goes lower than the min, it becomes the min) if you didnt know already

2 Likes

Does it need to be a point light? cause uhhh… i mean, i have a spot light, not a point light

Guys i need help, and i still can find the solution :frowning:

guys please :frowning:
i beg you, please, try your best, you can even try to help me at the little, pls guys, plsssss

It has to be a pointlight, doesnt really matter what its range or brightness is.

2 Likes