2DB
|
  |
| Joined: 18 Nov 2013 |
| Total Posts: 109 |
|
|
| 27 Nov 2013 05:15 PM |
I want to make a hyperlaser shotgun with accuracy. Where do I add the math.randoms to change accuracy so the shots all go different places? All the variables and functions were defined earlier so you don't have to sift through them.
local function OnActivated() for i=1, SHOT_NUMBER do if Tool.Enabled and Humanoid.Health > 0 then Tool.Enabled = false
FireSound:Play()
local handleCFrame = Handle.CFrame local firingPoint = handleCFrame.p + handleCFrame:vectorToWorldSpace(NOZZLE_OFFSET) local shotCFrame = CFrame.new(firingPoint, Humanoid.TargetPoint)
local laserShotClone = BaseShot:Clone() laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector * (BaseShot.Size.Z / 2)) local bodyVelocity = Instance.new('BodyVelocity') bodyVelocity.velocity = shotCFrame.lookVector * SHOT_SPEED bodyVelocity.Parent = laserShotClone laserShotClone.Touched:connect(function(otherPart) OnTouched(laserShotClone, otherPart) end) DebrisService:AddItem(laserShotClone, SHOT_TIME) laserShotClone.Parent = Tool --wait(0.6) -- FireSound length
Tool.Enabled = true end end end |
|
|
| Report Abuse |
|
|
2DB
|
  |
| Joined: 18 Nov 2013 |
| Total Posts: 109 |
|
|
| 27 Nov 2013 05:37 PM |
| I know it's a little early for a bump, but I'm the only viewing this thread. Help please? |
|
|
| Report Abuse |
|
|
2DB
|
  |
| Joined: 18 Nov 2013 |
| Total Posts: 109 |
|
| |
|
2DB
|
  |
| Joined: 18 Nov 2013 |
| Total Posts: 109 |
|
| |
|
2DB
|
  |
| Joined: 18 Nov 2013 |
| Total Posts: 109 |
|
|
| 27 Nov 2013 06:54 PM |
| Bump, again, again, again. |
|
|
| Report Abuse |
|
|
2DB
|
  |
| Joined: 18 Nov 2013 |
| Total Posts: 109 |
|
|
| 27 Nov 2013 07:56 PM |
| Bump, again, again, again, again. |
|
|
| Report Abuse |
|
|
mic144
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 1598 |
|
|
| 27 Nov 2013 08:02 PM |
Where ever your mouse is pointing you should do: .Position+Vector3.new(math.random(-1, 2), math.random(-1,1), math.random(-1, 1))
-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ -- |
|
|
| Report Abuse |
|
|
2DB
|
  |
| Joined: 18 Nov 2013 |
| Total Posts: 109 |
|
|
| 27 Nov 2013 08:04 PM |
| Thank you for a response at last! |
|
|
| Report Abuse |
|
|
mic144
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 1598 |
|
|
| 27 Nov 2013 08:07 PM |
I'm not too 'knowledgeful' or experienced with RayCasting or anything to do with Mouses but I'm pretty sure that should work.
-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ -- |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2013 08:09 PM |
What the person above said will make any time your mouse is on a close object, you have horrible accuracy, and when you have the mouse on a far away object, it is really accurate. To solve this, i'd do something like:
vel = (mouse.Position-char.Torso.Position).unit
vel = vel + Vector3.new(math.random(-10,10)/20,math.random(-10,10)/20,math.random(-10,10)/20)
Which will make it just as accurate at all ranges. |
|
|
| Report Abuse |
|
|
2DB
|
  |
| Joined: 18 Nov 2013 |
| Total Posts: 109 |
|
| |
|