|
| 08 Mar 2015 02:51 PM |
Here is the code.. I am making a animatronic game. I am trying to make the animatronics freeze when they get viewed by the camera, and this is what I have on mind. The loops are kind of laggy...
while true do Cameras = {script.Parent.CamA, script.Parent.CamB, script.Parent.CamC} Cam = Cameras[math.random(1,#Cameras)] game.Workspace.Camera2.Value = Cam
for i = 1,25,1 do for i,v in pairs(game.Players:GetChildren()) do if v.Character:FindFirstChild("Chest") then local ray = Ray.new(Cam.CFrame.p,(v.Character.Torso.CFrame.p - Cam.CFrame.p).unit * 500) local ignore = script.Parent local hit, position = workspace:FindPartOnRay(ray, ignore)
local tor = v.Character.Torso local mag = ((position - tor.Position).Magnitude)
if hit.Name == "HitBox" then tor.Parent.Humanoid.WalkSpeed = 0 for i,v in pairs(tor.Parent:GetChildren()) do if v:IsA("BasePart") then v.Anchored = true end end
else tor.Parent.Humanoid.WalkSpeed = 16 for i,v in pairs(tor.Parent:GetChildren()) do if v:IsA("BasePart") then v.Anchored = false end end end end end wait(0.1) end end
|
|
|
| Report Abuse |
|
|
|
| 08 Mar 2015 02:54 PM |
| Your gonna need multiple raysfrom the camera |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Mar 2015 02:57 PM |
| Frankly, I wouldn't use rays at all. I would use Stravant's ScreenSpace module to see if the object is on screen, and then... oh wait... And THEN I would raycast, if it was on screen. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 08 Mar 2015 03:04 PM |
| It converts 3D to 2D space and vise-versa. |
|
|
| Report Abuse |
|
|
|
| 08 Mar 2015 03:08 PM |
| Sorry for asking so many questions, but how do I use it? I know how to run a module script, but this script doesn't really give any instructions on how to use it correctly. |
|
|
| Report Abuse |
|
|
|
| 08 Mar 2015 03:12 PM |
| I can help you tomorrow. Now, I am very tired. |
|
|
| Report Abuse |
|
|
| |
|