|
| 10 Feb 2013 10:37 AM |
I want to raycast to the ground, 20 studs above the player, and the ray should always go to a random direction, instead of straight down to the player. How do I accomplish this "spread", anyone able to help me out here?
game.Players.LocalPlayer.CharacterAdded:wait() local char = game.Players.LocalPlayer.Character
while true do wait(1) local pos = char.Torso.Position + Vector3.new(0, 20, 0) --raycast end |
|
|
| Report Abuse |
|
|
| |
|
|
| 10 Feb 2013 12:49 PM |
while true do wait(1) local pos = char.Torso.Position local ray = Ray.new(pos + Vector3.new(0,20,0),pos + Vector3.new(math.random(-50,50),-1000,math.random(-50,50)) local part,endpoint = Workspace:FindPartOnRay(ray) end
Haven't tested. Edit the -50,50 for more/less radius of randomness. |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2013 02:20 PM |
You left out one parenthesis, but it doesn't work, tried to use it like this:
while true do wait(1) for i = 1, 5 do local pos = char.Torso.Position local ray = Ray.new(pos + Vector3.new(0,20,0),pos + Vector3.new(math.random(-50,50)),-1000,math.random(-50,50)) local hit,position = Workspace:FindPartOnRay(ray) if hit then if hit.ClassName == "Part" then if hit.Material == "Grass" then --draw shrubbery local m = Instance.new("Part", workspace) m.Position = position m.Anchored = true m.CanCollide = false end end end end end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 10 Feb 2013 08:25 PM |
while true do wait(1) for i = 1, 5 do local pos = char.Torso.Position local ray = Ray.new(pos + Vector3.new(0,20,0),pos + Vector3.new(math.random(-50,50),-1000,math.random(-50,50))) local hit,position = Workspace:FindPartOnRay(ray) if hit then if hit.ClassName == "Part" and hit.Material == "Grass" then --draw shrubbery local m = Instance.new("Part", Workspace) m.Position = Vector3.new(position) m.Anchored = true m.CanCollide = false end end end end
Try this |
|
|
| Report Abuse |
|
|