|
| 15 Apr 2015 12:18 PM |
| Don't ask why. I need a script that detects the darkness somehow, but I have no idea where to start. Help? |
|
|
| Report Abuse |
|
|
|
| 15 Apr 2015 12:23 PM |
| This is not possible unless you use raycasting, you know the settings in Lighting, and you have a list of every light in your game. |
|
|
| Report Abuse |
|
|
BowtieMod
|
  |
| Joined: 01 Apr 2013 |
| Total Posts: 804 |
|
| |
|
|
| 15 Apr 2015 12:41 PM |
Not fun enough. I considered doing it, but it is somewhat boring.
Guess what though? It can work with natural light too, because of GetSunDirection. |
|
|
| Report Abuse |
|
|
BowtieMod
|
  |
| Joined: 01 Apr 2013 |
| Total Posts: 804 |
|
|
| 15 Apr 2015 12:46 PM |
Coool
Wish they exposed the voxel functions for the light .3. |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2015 01:33 PM |
| I am thinking on making a game on the Vashta Nerada. "The flesh devouring shadows" So ROBLOX has locked the function. Great. ROBLOX! Y U DO DIS! MAIK DE FUNCTION! I am open to ideas. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 16 Apr 2015 01:34 PM |
| Seems like too much trouble for a small outcome. |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 16 Apr 2015 01:35 PM |
It is too much trouble for a small outcome. Is detecting darkness a necessity?
-=Robo=- |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2015 01:43 PM |
| Not necessarily. But it would sure make it a lot easier. I have a few ideas if it is not possible to directly detect the shadows. |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2015 01:54 PM |
| I already pretty much told you how to. Just get the direction of the sun, and send a ray to it. If it doesn't hit anything, it is not a shadow. If it does hit something, then iterate through all the lights in your game, raycast to them based on their range, and if any of the rays doesn't hit anything, then it is not a shadow. |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2015 02:00 PM |
| Ok,thats perfect. But my problem is that I don't care about the sun, I am talking dynamic lights. |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2015 02:02 PM |
| You probably told me all I really need to know, but I have no experience in raycasting. |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 16 Apr 2015 02:04 PM |
| http://wiki.roblox.com/index.php?title=Raycasting |
|
|
| Report Abuse |
|
|
|
| 16 Apr 2015 02:05 PM |
I think CloneTrooper1019 did this
Look at his Twitter or something. I remember seeing it |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 17 Apr 2015 12:53 PM |
@Novus, his example isn't open sourced.
-=Robo=- |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Apr 2015 01:07 PM |
| Why ask him how when I already told you the best way? |
|
|
| Report Abuse |
|
|
|
| 20 May 2015 11:48 AM |
| I know it's been a while since I came back to this post, but we didn't really finished what we started. Could someone put some time into making a darkness detector for all to use? |
|
|
| Report Abuse |
|
|
|
| 20 May 2015 01:05 PM |
Sorry, it's fairly basic.. But it should get the job done.
ModuleScript: ------------ local function Recursion(Par, Tab) if not Tab then Tab = {} end for _,a in pairs(Par:GetChildren()) do if a:IsA("PointLight") then table.insert(Tab, a) return Tab else Tab = Recursion(a, Tab) end end return Tab end
local this = {}
this.DetectLevel = function(self, Pos, Par) local Lights; if Par then Lights = Recursion(Par) else Lights = Recursion(game.Workspace) end local Low; for _,a in pairs(Lights) do if not Low then Low = (a.Brightness * a.Range) - (a.Parent.Position - Pos).magnitude elseif (a.Brightness * a.Range) - (a.Parent.Position - Pos).magnitude > Low then Low = (a.Brightness * a.Range) - (a.Parent.Position - Pos).magnitude end end if Low < 0 then Low = 0 end return Low end
return this ------------
Normal script: -------------
Light = require(script.ModuleScript) wait(5) while wait(1) do local x = Light:DetectLevel(game.Players.Player1.Character.Torso.Position) print(x) end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 20 May 2015 01:28 PM |
| Epic, can you explain the script? |
|
|
| Report Abuse |
|
|
|
| 20 May 2015 01:35 PM |
| Thats not what he wanted, he wants a script that detects where shadows are, which can also be said as, where light is not shining. |
|
|
| Report Abuse |
|
|
|
| 20 May 2015 01:36 PM |
| I think you'd have to strip the voxel lighting down to the core to create this, Ill also bee needing something similar for a game ill be making in 2 years. |
|
|
| Report Abuse |
|
|
|
| 20 May 2015 01:40 PM |
Every light instance has a range property. Spotlights have an angle property. To check if a point in world space is dark, do this: For each light in the game, compare the distance from that light to the point with that lights range. If the distance is smaller than the range, that point might be illuminated by that light. Then, for each light in range, check if there is line of sight. Then, if the light is a spotlight, check if it points close enough to the point. |
|
|
| Report Abuse |
|
|