Making BodyForce Faster

  1. What do you want to achieve? i have a guided missile that flys using bodyforce. i want the missile to fly faster

  2. What is the issue? it flies really slowly

  3. What solutions have you tried so far? i looked everywhere and even tried putting a humanoid inside of it but that just breaks everything

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

function fire(vTarget)
	local vCharacter = plr.Character
	local vHandle = vCharacter:findFirstChild("HumanoidRootPart")
	if vHandle == nil then
	end
	local direction = vTarget - vHandle.Position
	direction = computeDirection(direction)
	local missile = Rocket:clone()
	local pos = Vector3.new(939.887, 291.665, -812.581) + (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 = computeDirection(vCharacter.Humanoid.TargetPoint - missile.Position) * 20.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)
	local cam = workspace.CurrentCamera
cam.CameraSubject = missile
cam.CameraType = "Follow"
active = true
local parent = plr.Character
	
while(active) do
		direction =  computeDirection(mouse.Hit.Position - missile.Position)
	missile.Velocity = direction * 20.0
 
	--The below line of code wasn't in the tutorial.  It's optional and just points the missile in the right direction
		missile.CFrame = CFrame.new(missile.Position,  missile.Position + direction) * CFrame.Angles(0, 0, math.pi/2)
	wait()
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

while(active) do
		direction =  computeDirection(mouse.Hit.Position - missile.Position)
	missile.Velocity = direction * 150
 
	--The below line of code wasn't in the tutorial.  It's optional and just points the missile in the right direction
		missile.CFrame = CFrame.new(missile.Position,  missile.Position + direction) * CFrame.Angles(0, 0, math.pi/2)
	wait()
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.