Currently working on a top-down rocket launcher, similar to that of the IRL Javelin. A player locks onto a target, shoots the rocket, and the rocket first travels to a midpoint between the target and launching player that is 50 studs above the target; after reaching that midpoint, the rocket travels down towards the target.
However, that is not what happens at all. The movement described above is pretty sporadic and never really reaches its target, as you can see in this video
I am using RocketPropulsion
, which I know is depreciated, because:
- IMO, it’s movement is a lot better/cooler than its replacement,
LineForce
-
RocketPropulsion
has more methods and proporties, likeReachedTarget
andTargetOffset
than what LineForce has to offer.
For reference, I am using the ROBLOX Heat Seeking Missile Launcher as a base for this system; the code I show below will be familiar to those who have worked with it before
Here is the code I am using:
local rocketPropulsion:RocketPropulsion = RocketClone:FindFirstChild('RocketPropulsion')
if rocketPropulsion then
if not LockedPlayer then
----- backup just in case...
local direction = (targetPosition - RocketClone.Position).unit
rocketPropulsion.TargetOffset = RocketClone.Position + (direction * TARGET_OVERSHOOT_DISTANCE)
rocketPropulsion:Fire()
else
local rpClone = rocketPropulsion:Clone()
rocketPropulsion.Target = LockedPlayer.Character.PrimaryPart or LockedPlayer.Character:FindFirstChild('HumanoidRootPart')
rocketPropulsion.Parent = nil
rpClone.Parent = RocketClone
local pos1:Vector3 = RocketClone.Position
local pos2:Vector3 = LockedPlayer.Character.PrimaryPart.Position
local pos3:Vector3 = (pos1 + pos2)/2
rpClone.TargetOffset = pos3 + Vector3.new(0,(pos2.Y+50),0)
rpClone:Fire()
rpClone.ReachedTarget:Once(function()
rpClone:Abort()
rpClone:Destroy()
rocketPropulsion.Parent = RocketClone
rocketPropulsion:Fire()
end)
end
end
Basically, I create a clone of the original RocketPropulsion, make that set to the midpoint position, fire the clone, and when the clone has reached its target, I fire the original RocketPropulsion that is supposed to go the target.
How can I fix this?