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: Rocket inaccuracy

Previous Thread :: Next Thread 
Wings96 is not online. Wings96
Joined: 11 Nov 2010
Total Posts: 191
14 Feb 2012 02:03 PM
Id like to modify a standard rocket launcher so that the rocket slowly curves in one direction instead of flying straight and being 100% accurate. how would I do this?
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
14 Feb 2012 02:45 PM
The best way is to make your own instead of free modeling it.
Report Abuse
Wings96 is not online. Wings96
Joined: 11 Nov 2010
Total Posts: 191
14 Feb 2012 03:10 PM
If I could script, would I be posting here? no. I can modify scripts decently, and Im building the launcher body. If you dont have something helpfull to say, please dont say anything.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
14 Feb 2012 03:10 PM
"If I could script, would I be posting here?"

Yes.

† KMXD †
Report Abuse
fizzman is not online. fizzman
Joined: 08 Apr 2008
Total Posts: 141
14 Feb 2012 04:00 PM
The guy is asking for help. Don't get all upity on those who aren't "scripting masters".
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 Feb 2012 04:01 PM
The point is, this forum isn't for asking people to make things for you, and we *certainly* don't suggest free models. The whole point of this forum is to *help* you learn by fixing your scripts and/or helping you understand individual concepts.

You now have +10 INT from this post. Oh, by the way, Like an __AWESOME__ boss-
Report Abuse
tiger33333321 is not online. tiger33333321
Joined: 28 Mar 2010
Total Posts: 2115
14 Feb 2012 04:03 PM
>If I could script, would I be posting here? no. I can modify scripts decently, and Im building the launcher body. If you dont have something helpfull to say, please dont say anything.

YES YES YES
SERVED HIM ON A COLD PLATE, MAN

Oh, and, on topic, I think `Velocity = math.random` might do it, idk

http://www.roblox.com/My/Groups.aspx?gid=80738
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 Feb 2012 04:05 PM
tiger, Penguine is actually right. Nobody should come on this forum asking for a request.

You now have +10 INT from this post. Oh, by the way, Like an __AWESOME__ boss-
Report Abuse
tiger33333321 is not online. tiger33333321
Joined: 28 Mar 2010
Total Posts: 2115
14 Feb 2012 04:08 PM
doesn't mean you have to be mean about it.

http://www.roblox.com/My/Groups.aspx?gid=80738
Report Abuse
RealPerson is not online. RealPerson
Joined: 16 Jun 2009
Total Posts: 2295
14 Feb 2012 04:12 PM
What request did he ask again... Because I don't see any reason to whine about his post.
Report Abuse
Wings96 is not online. Wings96
Joined: 11 Nov 2010
Total Posts: 191
14 Feb 2012 04:18 PM
I want help with making the rocket in this launcher -> http://www.roblox.com/A-W-C-XM-90-ATW-item?id=72412918 curve slightly after launch. I have a slight idea of how to do it, (I think math random (insert # here) and a bodygyro will come into play). but I really dont have a good grasp on scripting. so, if someone could point me (or do a little more than that) in the right direction, it would be much appreciated.
Report Abuse
Grove537 is not online. Grove537
Joined: 05 Feb 2010
Total Posts: 3478
14 Feb 2012 04:21 PM
Try reading the Wiki on BodyGyro :)
Report Abuse
Wings96 is not online. Wings96
Joined: 11 Nov 2010
Total Posts: 191
14 Feb 2012 04:24 PM
read.... hmm, maybe bodygyro isnt what Im looking for. The idea is to just nudge the rocket ever so slightly in a random direction... maybe rocketpropulsion?
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
14 Feb 2012 04:45 PM
In the rocket launcher, open up the script called RocketLauncherScript. Find line 85, it looks like this:
floatForce.force = Vector3.new(0, missile:GetMass() * 196.1, 0.0)
Change it to something like this:
floatForce.force = Vector3.new(math.random(-2, 2), missile:GetMass() * 196.1, math.random(-2, 2))

That should nudge it in a random direction. If the nudge is too much or too little, adjust the values in the math.random()s
Report Abuse
Wings96 is not online. Wings96
Joined: 11 Nov 2010
Total Posts: 191
14 Feb 2012 04:55 PM
This rocket doesnt even have a script called that, much less anything in the scripts that looks like that. The two main scripts of this are the Serverlauncher and Rocketscript.

A sample from the Serverlauncher script- I have a feeling the values I need to modify are in here, am I correct?

function fire(vTarget)

local vCharacter = Tool.Parent;

local vHandle = Tool:findFirstChild("Handle")
if vHandle == nil then
print("Handle not found")
return
end

local dir = vTarget - vHandle.Position

dir = computeDirection(dir)

local missile = Rocket:clone()

local pos = vHandle.Position + (dir * 6)

--missile.Position = pos
missile.CFrame = CFrame.new(pos, pos + dir)

local creator_tag = Instance.new("ObjectValue")

local vPlayer = game.Players:playerFromCharacter(vCharacter)

if vPlayer == nil then
print("Player not found")
else
if (vPlayer.Neutral == false) then -- nice touch
missile.BrickColor = vPlayer.TeamColor
end
end

creator_tag.Value =vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = missile

missile.RocketScript.Disabled = false

missile.Parent = game.Workspace
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
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
14 Feb 2012 04:57 PM
Eh?
I'm looking in the toolbox in "Weapons" under Roblox Sets.
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
14 Feb 2012 05:00 PM
There are the rocket launchers with Ammo/MaxAmmo/StoredAmmo.
They don't shoot accurately; the rocket eventually falls to the ground instead of flying forever.
My friend also used one that was a fail.
Sometimes, the fail one had the rocket fly to the right or left when it hit something instead of exploding.
Report Abuse
Wings96 is not online. Wings96
Joined: 11 Nov 2010
Total Posts: 191
14 Feb 2012 05:09 PM
This rocket deletes the projectile after a set distance. Also, I need it to bank in a random direction once its fired, not after it hits something.
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
14 Feb 2012 05:10 PM
Can you post the entire script(s)?
Report Abuse
Wings96 is not online. Wings96
Joined: 11 Nov 2010
Total Posts: 191
14 Feb 2012 05:11 PM
RocketScript:

r = game:service("RunService")

shaft = script.Parent
position = shaft.Position

script.Parent.Explosion.PlayOnRemove = true -- play explosion sound when projectile removed from game

function fly()
direction = shaft.CFrame.lookVector * 4
position = position + direction
error = position - shaft.Position
shaft.Velocity = 4*error
end

function blow()
swoosh:stop()
explosion = Instance.new("Explosion")
explosion.Position = shaft.Position
explosion.BlastRadius = 6


-- find instigator tag
local creator = script.Parent:findFirstChild("creator")
if creator ~= nil then
explosion.Hit:connect(function(part, distance) nukeHeli(part) onPlayerBlownUp(part, distance, creator) end)
end

explosion.Parent = game.Workspace
connection:disconnect()
wait(.1)
for i=1, 4 do
local smokepart = Instance.new("Part")
smokepart.Size = Vector3.new(1,1,1)
smokepart.Transparency = 1
smokepart.Position = shaft.Position + Vector3.new(math.random(-7,7),5,math.random(-7,7))
local smoke = Instance.new("Smoke")
smoke.Parent = smokepart
smoke.Color = Color3.new(0,0,0)
smoke.Opacity = 1
smoke.Size = 8
smoke.RiseVelocity = 5
smokepart.Parent = workspace
local gyro = Instance.new("BodyGyro")
gyro.Parent = smokepart
game:GetService("Debris"):AddItem(smokepart, 10)
end
shaft:remove()
end

function onPlayerBlownUp(part, distance, creator)

if part.Name == "Head" then

local humanoid = part.Parent.Humanoid
tagHumanoid(humanoid, creator)
end
end

function nukeHeli(part)

if part.Parent.Name == "Heli" or part.Parent.Name == "Jeep" or part.Parent.Name == "Turret" then

part.Parent.Health.Value = 0

elseif part.Parent.Name == "Generator" then

part.Parent.Health.Value = part.Parent.Health.Value - 200

end
end

function tagHumanoid(humanoid, creator)
-- tag does not need to expire iff all explosions lethal

if creator ~= nil then
local new_tag = creator:clone()
new_tag.Parent = humanoid

end
end

function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then

tag.Parent = nil
end
end
end

t, s = r.Stepped:wait()

swoosh = script.Parent.Swoosh
swoosh:play()

d = t + 10.0 - s
connection = shaft.Touched:connect(blow)

while t < d do
fly()
t = r.Stepped:wait()
end

-- at max range
script.Parent.Explosion.PlayOnRemove = false
swoosh:stop()
shaft:remove()
Report Abuse
Wings96 is not online. Wings96
Joined: 11 Nov 2010
Total Posts: 191
14 Feb 2012 05:12 PM
Server Launcher:

local Rocket = Instance.new("Part")
local Tool = script.Parent

Rocket.Locked = true
Rocket.BackSurface = "Smooth"
Rocket.BottomSurface = "Smooth"
Rocket.FrontSurface = "Smooth"
Rocket.LeftSurface = "Smooth"
Rocket.RightSurface = "Smooth"
Rocket.TopSurface = "Smooth"
Rocket.Size = Vector3.new(1,1,5)
Rocket.BrickColor = BrickColor.new(23)
rmesh = Tool.Mesh:clone()
rmesh.Parent = Rocket
Tool.RocketScript:clone().Parent = Rocket
Tool.Explosion:clone().Parent = Rocket
Tool.Swoosh:clone().Parent = Rocket


function fire(vTarget)

local vCharacter = Tool.Parent;

local vHandle = Tool:findFirstChild("Handle")
if vHandle == nil then
print("Handle not found")
return
end

local dir = vTarget - vHandle.Position

dir = computeDirection(dir)

local missile = Rocket:clone()

local pos = vHandle.Position + (dir * 3)

--missile.Position = pos
missile.CFrame = CFrame.new(pos, pos + dir)

local creator_tag = Instance.new("ObjectValue")

local vPlayer = game.Players:playerFromCharacter(vCharacter)

if vPlayer == nil then
print("Player not found")
else
if (vPlayer.Neutral == false) then -- nice touch
missile.BrickColor = vPlayer.TeamColor
end
end

creator_tag.Value =vPlayer
creator_tag.Name = "creator"
creator_tag.Parent = missile

missile.RocketScript.Disabled = false

missile.Parent = game.Workspace
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

Tool.Enabled = true
function onActivated()
if not Tool.Enabled then
return
end

Tool.Enabled = false

local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end

local targetPos = humanoid.TargetPoint

fire(targetPos)
script.Parent.Name = "Out of ammo"
end


script.Parent.Activated:connect(onActivated)
Report Abuse
DrAgonmoray is not online. DrAgonmoray
Joined: 29 Jul 2008
Total Posts: 17428
14 Feb 2012 05:16 PM
function fly()
direction = shaft.CFrame.lookVector * 4
position = position + direction
error = position - shaft.Position + Vector3.new(math.random(-2, 2), 0, math.random(-2, 2))
shaft.Velocity = 4*error
end

Try that, in the first script
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
14 Feb 2012 05:28 PM
@ElectricBlaze

I wish more ppl would read that.


~= Pointless siggy. Ujelly? =~
Report Abuse
Wings96 is not online. Wings96
Joined: 11 Nov 2010
Total Posts: 191
14 Feb 2012 05:28 PM
Rocket wobbles a bit but continues along a straight axis. would increasing the parameters of the math.random statments change it?I have a feeling itll just make the wobble bigger... also, to clarify, I'm looking for the rocket NOT to fly in a straight path.
Report Abuse
Wings96 is not online. Wings96
Joined: 11 Nov 2010
Total Posts: 191
14 Feb 2012 05:59 PM
Yeah, not the effect im looking for at all.
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