generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: When missiles go straight.

Previous Thread :: Next Thread 
imcoolfire8 is not online. imcoolfire8
Joined: 23 Nov 2009
Total Posts: 3008
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
Candymaniac is not online. Candymaniac
Joined: 08 Oct 2009
Total Posts: 8985
25 Mar 2012 10:12 AM
Uuh, what are you trying to do exactly?

"Knowledge talks, wisdom listens."
Report Abuse
imcoolfire8 is not online. imcoolfire8
Joined: 23 Nov 2009
Total Posts: 3008
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
Candymaniac is not online. Candymaniac
Joined: 08 Oct 2009
Total Posts: 8985
25 Mar 2012 10:27 AM
But, it's the same - they all go straight ?

"Knowledge talks, wisdom listens."
Report Abuse
imcoolfire8 is not online. imcoolfire8
Joined: 23 Nov 2009
Total Posts: 3008
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 is not online. 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
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
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
mikeyman10ash is not online. mikeyman10ash
Joined: 29 Aug 2010
Total Posts: 30299
25 Mar 2012 11:37 AM
@crazy

Because you're good at math and scripting and st00fz. :)
Report Abuse
imcoolfire8 is not online. imcoolfire8
Joined: 23 Nov 2009
Total Posts: 3008
25 Mar 2012 12:40 PM
@grimm343
Exactly
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image