-
So I been trying to get into learning pathfindingservice and stuff because it can be usefully for many different things, including making a TDF game.
-
The main issue right now is this one line of code I don’t really understand so if you guys could help me that would be cool
if v.Action == Enum.PathWaypointAction.Jump then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
So basically, I don’t understand the point of setting the waypoint.action = Enum.PathWaypointAction.Jump cause by default doesn’t the npc/humanoid walk to the given location so is this if statement even going to happened? so would It be better if I did this instead.
if v.Action == Enum.PathWaypointAction.Walk then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
- I tried looking up the definition/what it does on the devhub but doesn’t really give me the answer I need, tried asking in discord server still no.
Here is the fulll code
local PathFindingService = game:GetService("PathfindingService")
local Humanoid = script.Parent:WaitForChild("Humanoid")
local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
local Path = PathFindingService:CreatePath()
Path:ComputeAsync(HumanoidRootPart.Position,workspace.zend.Position)
for i,v in pairs(Path:GetWaypoints()) do
if v.Action == Enum.PathWaypointAction.Jump then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
Humanoid:MoveTo(v.Position)
Humanoid.MoveToFinished:wait(.25)
end