Missile system lock lost when velocity is changed

  1. What do you want to achieve? Keep it simple and clear!
    Make the missile not miss when the velocity of a target is changed.
  2. What is the issue? Include screenshots / videos if possible!
    The missile misses when the BodyVelocity of the target changes.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried looking for solutions on the devforum but so far no luck.
    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!
local count = false
local main = workspace.rocketthing
local RunService = game:GetService("RunService")
local tweenService = game:GetService("TweenService")

print(workspace.Part.Size.Magnitude)

function flight()
	local oldVel = workspace.Part.BodyVelocity.Velocity
	--print(math.floor(workspace.Part.Velocity.Magnitude + .5))
	local timepassed = 0
	local t = math.floor(workspace.Part.BodyVelocity.Velocity.Magnitude/50 + .5)
	print(t)

	local pos = workspace.Part.Position + workspace.Part.Velocity * t 

	local distance = (main.Position - pos).Magnitude+workspace.Part.Size.Magnitude
	local speed = math.floor(distance / t) + workspace.Part.Velocity.Magnitude/15

	main.CFrame = CFrame.lookAt(main.Position, pos)

	while task.wait() do

		--local timeInAir = math.floor(distance / speed)
		--local dist = speed * timeInAir
		main.CFrame = CFrame.lookAt(main.Position, pos)

		local thrust = main.BodyVelocity

		print(speed)

		thrust.Velocity = main.Attachment.WorldCFrame.LookVector * speed

		main.Touched:Connect(function(hit)
			local explosion = Instance.new("Explosion")
			explosion.Position = main.Position
			explosion.Parent = workspace
			explosion.DestroyJointRadiusPercent = 100
			explosion.BlastPressure = 10000
			explosion.BlastRadius = 30
			
			print("Hit")
			explosion.Hit:Connect(function(hit)
				print("Hit")
				if hit:IsA("BasePart") then
					hit.Material = Enum.Material.CorrodedMetal	
					
					print("adding fire")
					local fire = Instance.new("Fire")
					fire.Size = 30
					fire.Heat = 25
					fire.Parent = hit
					print("Fire added")
				end
			end)

			main:Destroy()
			workspace.Part:Destroy()
			--script:Destroy()
		end)

		if workspace.Part.BodyVelocity.Velocity ~= oldVel then
			print("Thing")
			flight()
			oldVel = workspace.Part.BodyVelocity.Velocity
			break
		else
			oldVel = workspace.Part.BodyVelocity.Velocity
		end
	end
end

flight()

This is the current script I have right now.

Any help is appreciated!

Well the reason that your missle system lock doesn’t work when its changed is because yk thats how you dodge an actual missle. Changing your velocity.

Your system is working like an actual jet system, though i’m not sure how you could fix this.

Maybe look up some military documents or smth.

Note:
Lmao I thought about this, you probably can’t if the world’s militaries with billions in fundings cant.

After looking it up, the worlds militaries countered this by just giving the missles the ability to change their course by putting some fuel in em.

You could replicate this by giving the missles a max amount of change when firing, then if the targets velocity change recalculate their velocity,direction etc.

2nd Note:
**funny thing your topic here is one of the main ones that come up in google search **

You did get one thing right that was me recalculating the speed, lock, and other stuff, although that is literally whats causing the lock to be lost

My point is you can’t stop the lock from being lost, unless you allow the missle to “course correct” in mid air. this is why heat seeking missles are the standard, they track and someone can’t just slow down to dodge them.

Is there anyway to replicate correcting its course perfectly?

Absolutely.

If the velocity of the target changes, then just re run your calculations.

You could check the velocity of the goal via Stepped.

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