Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

(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

1 comment

0

I guess i could make this work.

This discussion is preserved as it was. New answers, comments, and votes are closed.