im2awsm
|
  |
| Joined: 25 Aug 2010 |
| Total Posts: 2295 |
|
|
| 09 Mar 2014 10:50 PM |
So I'm trying to make an NPC which shoots rockets out of their arm. I borrowed scripts from the Linked Rocket Launcher script, but don't quite understand it, and can't get it working. (Rocket is defined, it is a brick)
function blow(hit, missile) if missile == nil then return end explosion = Instance.new("Explosion") explosion.Position = missile.Position wait(.1) if missile then missile:Remove() end end
function computeDirection(vec) local lenSquared = vec.magnitude * vec.magnitude local invSqrt = 1 / math.sqrt(lenSquared) return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt) end
function fireRocket(vTarget) local direction = game.Workspace.SandGuardian["Left Arm"].CFrame.lookVector direction = computeDirection(direction) local missile = Rocket:clone() local pos = game.Workspace.SandGuardian["Left Arm"].Position + (direction * 10.0) missile.CFrame = CFrame.new(pos, pos + direction) * CFrame.Angles(math.pi/2, 0, 0)
local floatForce = Instance.new("BodyForce") floatForce.force = Vector3.new(0, missile:GetMass() * 196.1, 0.0) floatForce.Parent = missile
missile.Velocity = direction * 20.0
missile.Parent = game.Workspace
missile.Touched:connect(function(hit) blow(hit, missile) end)
game.Debris:AddItem(missle, 10) end |
|
|
| Report Abuse |
|
|
b3njam1n
|
  |
| Joined: 05 Nov 2007 |
| Total Posts: 19389 |
|
| |
|
transIate
|
  |
| Joined: 20 Jun 2013 |
| Total Posts: 2699 |
|
| |
|
im2awsm
|
  |
| Joined: 25 Aug 2010 |
| Total Posts: 2295 |
|
| |
|
transIate
|
  |
| Joined: 20 Jun 2013 |
| Total Posts: 2699 |
|
| |
|
im2awsm
|
  |
| Joined: 25 Aug 2010 |
| Total Posts: 2295 |
|
|
| 09 Mar 2014 11:57 PM |
| Yeah. It didn't help at all. |
|
|
| Report Abuse |
|
|
transIate
|
  |
| Joined: 20 Jun 2013 |
| Total Posts: 2699 |
|
| |
|
im2awsm
|
  |
| Joined: 25 Aug 2010 |
| Total Posts: 2295 |
|
| |
|
transIate
|
  |
| Joined: 20 Jun 2013 |
| Total Posts: 2699 |
|
| |
|
|
| 10 Mar 2014 04:28 AM |
You know where the activated event is? Like, the function towards the bottom that fire when a player clicks? Make it fire every 7 seconds (the reload time) by using a while loop or something.
As for the aiming, you need to find the nearest player's torso. |
|
|
| Report Abuse |
|
|