I wan’t to make a rocket missile, and the problem is the movement system, i want to achieve something like this: (Example of a walking player)
I wan’t to keep something like curves and rotation.
Tried to keep short, could you help me? Thanks.
I wan’t to make a rocket missile, and the problem is the movement system, i want to achieve something like this: (Example of a walking player)
Hi!
Could you be a bit more specific please? The graph confused me. Are you trying to make a guided missile? Or are you asking for a pathfinding method? ![]()
Yeah, a Pathfinding method, but made by me, not controlled by the service. I didn’t found another title for this
You could track the target position in a loop and continuously change the projectile CFrame to approach and face the objetive’s previous position, i. e., what you call a breakpoint. In this case, the missile would have to be anchored.
Roblox has their own Pathfinding service that creates the breakpoints areadly!
Service: PathfindingService | Documentation - Roblox Creator Hub
Tutorial: Character Pathfinding | Documentation - Roblox Creator Hub
I thought Pathfinding was for players, I want to make a missile to move in a way that I want.
How I do that? Or any script showcase?
I believe you can use PathfindingService to generate nodes, then I personally would use TweenService to make the Rocket smoothly travel to each of these nodes.
Yes Pathfinding can be used for Players but if ComputeAsync just takes positions attributes so you can put your own positions in and then tween the Rocket through those points
Could you provide me a code for example?? Thanks if you do ![]()
Here’s some pseudo code:
local VELOCITY, TIME = 50, 0.3
local newPath = PathfindingService:CreatePath(rocket.Size.X, rocket.Size.Z)
newpath:ComputeAsync(rocket.Position, endPosition)
local waypoints = newPath:GetPath()
for _, point in pairs(waypoints) do
local distance = (rocket.Position - waypoint.Position).magnitude
rocket.CFrame = CFrame.new(rocket.Position, point.Position)
local tween = TweenService:Create(rocket, TweenInfo.new(distance * TIME / VELOCITY, Enum.EasingStyle.Linear), {CFrame = CFrame.new(point.Position)})
tween:Play()
tween.Completed:Wait()
end
local explosion = Instance.new("Explosion")
explosion.Position = rocket.Position
exploision.Parent = workspace
Ok i changed some very little stuff since some stuff were not written:
local rocket = script.Parent
local PathfindingService = game:GetService("PathfindingService")
local TweenService = game:GetService("TweenService")
local endPosition = game.Workspace.AADA
local VELOCITY, TIME = 50, 0.3
local newPath = PathfindingService:CreatePath(rocket.Size.X, rocket.Size.Z)
newPath:ComputeAsync(rocket.Position, endPosition)
local waypoints = newPath:GetPath()
for _, point in pairs(waypoints) do
local distance = (rocket.Position - waypoints.Position).magnitude --waypoint was an unknown global.
rocket.CFrame = CFrame.new(rocket.Position, point.Position)
local tween = TweenService:Create(rocket, TweenInfo.new(distance * TIME / VELOCITY, Enum.EasingStyle.Linear), {CFrame = CFrame.new(point.Position)})
tween:Play()
tween.Completed:Wait()
end
local explosion = Instance.new("Explosion")
explosion.Position = rocket.Position
explosion.Parent = workspace
Well, testing this, an error appears:
17:37:10.644 - Unable to cast to Dictionary
17:37:10.646 - Stack Begin
17:37:10.648 - Script 'Workspace.Part.Script', Line 6
17:37:10.649 - Stack End
To be honest, I have never used PathfindingService, so I cannot help you ![]()
However, I’ve spotted an error at line 4. It should be local endPosition = workspace.AADA.Position, since ComputeAsync() (line 7) will expect Vector3 values, not objects. Beside this, I can’t really do much. Let’s hope another dev specialized on this can solve your error regarding CreatePath().
Perhaps you could try using splines.
This was not intended for actual use, however is an instance, not a Vector3, which is one issue.
local rocket = script.Parent
local PathfindingService = game:GetService("PathfindingService")
local TweenService = game:GetService("TweenService")
local endPosition = game.Workspace.AADA.Position
local VELOCITY, TIME = 50, 0.3
local newPath = PathfindingService:CreatePath()
newPath:ComputeAsync(rocket.Position, endPosition)
local waypoints = newPath:GetPath()
for _, point in pairs(waypoints) do
local distance = (rocket.Position - point.Position).magnitude -- i made a mistake, my bad
rocket.CFrame = CFrame.new(rocket.Position, point.Position)
local tween = TweenService:Create(rocket, TweenInfo.new(distance * TIME / VELOCITY, Enum.EasingStyle.Linear), {CFrame = CFrame.new(point.Position)})
tween:Play()
tween.Completed:Wait()
end
local explosion = Instance.new("Explosion")
explosion.Position = rocket.Position
explosion.Parent = workspace
The issue that causing it to error that I used the waypoints table, rather than the value, my bad. ![]()
I got an issue where GetPath() is not a member of Path. Why is that happening?