|
| 25 Mar 2012 10:05 AM |
I am trying to make it so that when you use the rocket laucher (In this case I have a lasor that I want the rocket to go straight) Here is a cut from the fire portion where it has Compute direction i have the line copyed and in -- on the same line so that if it doesnt work it wont be lost. function fire(vTarget) local vCharacter = Tool.Parent local vHandle = Tool:findFirstChild("A1") if vHandle == nil then print("Handle not found") return end local direction = vTarget - vHandle.Position direction = computeDirection(direction) local missile = Rocket:clone() local pos = vHandle.Position + (direction * 10.0) missile.CFrame = CFrame.new(pos, pos + direction) * CFrame.Angles(math.pi/2, 0, 0)
local creator_tag = Instance.new("ObjectValue")
local vPlayer = game.Players:GetPlayerFromCharacter(vCharacter)
if vPlayer == nil then print("Player not found") else if (vPlayer.Neutral == false) then -- nice touch missile.BrickColor = vPlayer.TeamColor end end
local floatForce = Instance.new("BodyForce") floatForce.force = Vector3.new(0, missile:GetMass() * 196.1, 0.0) floatForce.Parent = missile
missile.Velocity = direction * 200.0
creator_tag.Value = vPlayer creator_tag.Name = "creator" creator_tag.Parent = missile
missile.Parent = game.Workspace
if swooshSound then swooshSound:Play() end
missile.Touched:connect(function(hit) blow(hit, missile) end)
debris:AddItem(missile, 100.0) 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)--(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt) end |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 10:12 AM |
Uuh, what are you trying to do exactly?
"Knowledge talks, wisdom listens." |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 10:19 AM |
Make it so that when you click it just goes straight across a lasor point instead of clicking somewhere and sending it there Like I click on 50 and the handle is 20, i want it so it goes to the end of 20 not 50 |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 10:27 AM |
But, it's the same - they all go straight ?
"Knowledge talks, wisdom listens." |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 10:45 AM |
| I mean when you click it goes to where you click. I want is to when you click, it goes just forward. |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 25 Mar 2012 10:51 AM |
| I think that he means that it goes straight, relative to the missile launcher. |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 11:35 AM |
Gosh, why is the math so complex? My missiles in Perilous Skies, which are homing missiles and can predict future positions, uses no more than simple addition, subtraction, multiplication, and division |
|
|
| Report Abuse |
|
|
|
| 25 Mar 2012 11:37 AM |
@crazy
Because you're good at math and scripting and st00fz. :) |
|
|
| Report Abuse |
|
|
| |
|