|
| 24 Apr 2016 09:12 PM |
I am using the raycast script from the Roblox Wiki, and it doesn't seem to include any spread. Would this be easy to implement? How would I go about doing this?
Your reply was the most disappointing thing since my son. |
|
|
| Report Abuse |
|
|
|
| 24 Apr 2016 09:24 PM |
You should probably use CFrames for rotation, that would be the easiest way. Specify DegreesSpreadFromCenter, OriginVector3, TargetVector3, and Distance.
local Direction = CFrame.new(OriginVector3, TargetVector3) * CFrame.Angles(0, 0, math.random()*math.pi*2) * CFrame.Angles(math.random()*math.rad(DegreesSpreadFromCenter), 0, 0) local R Ray.new(OriginVector3, Direction.lookVector*Distance)
Use R in your raycasting. |
|
|
| Report Abuse |
|
|
DogeKip
|
  |
| Joined: 06 Mar 2011 |
| Total Posts: 6860 |
|
|
| 24 Apr 2016 09:43 PM |
This is how I did it
local distFirst = (mouse.Hit.p - tool.Barrel.CFrame.p).magnitude local spread = Vector3.new(math.random()*2-1,math.random()*2-1,math.random()*2-1)*distFirst * .012
[Redacted] |
|
|
| Report Abuse |
|
|
DogeKip
|
  |
| Joined: 06 Mar 2011 |
| Total Posts: 6860 |
|
|
| 24 Apr 2016 09:45 PM |
I forgot the raycast, here:
local distFirst = (mouse.Hit.p - tool.Barrel.CFrame.p).magnitude local spread = Vector3.new(math.random()*2-1,math.random()*2-1,math.random()*2-1)*distFirst * .012 local rayCast = Ray.new(tool.Barrel.Position, ((mouse.Hit.p - tool.Barrel.CFrame.p)+spread).unit*300)
[Redacted] |
|
|
| Report Abuse |
|
|
|
| 24 Apr 2016 09:46 PM |
| But that way, Doge, it spreads over the same area around the target, not same angles. |
|
|
| Report Abuse |
|
|
DogeKip
|
  |
| Joined: 06 Mar 2011 |
| Total Posts: 6860 |
|
|
| 24 Apr 2016 09:49 PM |
"But that way, Doge, it spreads over the same area around the target, not same angles."
You're wrong. You missed the part where I calculated the total magnitude and multiplied them out. This produces a relative spread rather than an absolute spread.
[Redacted] |
|
|
| Report Abuse |
|
|
|
| 24 Apr 2016 10:47 PM |
Thanks Doge.
Your reply was the most disappointing thing since my son. |
|
|
| Report Abuse |
|
|