Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i make it look like a model is walking towards a certain point?

Asked by 8 years ago

I am trying to animate a creature i am creating but i am having trouble getting it to look like it is walking towards a certain point. How would i do this using "SetPrimaryPartCFrame"?

1 answer

Log in to vote
0
Answered by 8 years ago

(THIS ONLY WORKS FOR ROBLOXIAN MODELS) Use pathfinding. Here are the steps to doing so. Make a part called Finish. It can be invisible, non-collidable, etc. It also doesn't have to be grouped to the humanoid. Put this model into your creature's model. (http://www.roblox.com/item.aspx?id=360628368) Then make a new script inside your creature's model and copy this code into it.

local maxDistance = 500 -- Maximum distance for the path

local dummy = script.Parent

local PathService = game:GetService("PathfindingService")

local path = PathService:ComputeRawPathAsync(dummy.Torso.Position, game.Workspace.Finish.Position, maxDistance)
if path.Status == Enum.PathStatus.Success then
    local points = path:GetPointCoordinates()
    for node = 1, #points do
        dummy.Humanoid:MoveTo(points[node])
        repeat
            local dis = (points[node]-dummy.Torso.Position).magnitude
            wait()
        until dis < 3
    end
else
    print("Computing path unsuccessful")
end
0
I guess i could make this work. raspyjessie 117 — 8y
Ad

Answer this question