How do I make a dummy walk?

:ledger: Note: I’m trying not to utilize MoveTo(), MoveToPoint(), etc.

:wave: Hello!

I’m currently trying to make a dummy that mirrors a players movements, I’ve already got the dummy to look in the correct direction, but now I need it to, walk. Is there a simple way to just make it walk in one direction? Or will I have to use MoveTo() / MoveToPoint()

Or, is there just an entirely easier way to make a dummy mirror a player.

3 Likes

Just copy the CFrame of the player and apply it to the dummy?

1 Like

you can use AlignPosition and AlignOrientation to make a custom mover, otherwise use CFrame as how @awry_y said.

That’s not what I’m trying to achieve.

I’m trying to make the dummy copy the players movement, so if the player walks forward, the dummy walks forward, if the player walks left, the dummy walks left, etc.

Use CFrames. I am sure that there is gonna be a specific difference between the two correct? If not then still use CFrames!! How!? Well… Use Humanoid.MoveDirection! How? First of all, get what direction the player walked in using the property listed above, then before setting rotation, multiply the rigs position with said property and you’re done!

I’m kind of confused on what your saying.

local moveDirection = humanoid.MoveDirection
dummy.PrimaryPart.CFrame = CFrame.new(moveDirection)

but I’m getting confused at the

Could you show me some sort of code block or example? The code I showed just makes the humanoid “point” towards the direction your walking, like this:

Using some of your replies, I got it to work!
Here’s the code I’m using, which bases the actual orientation of the dummy to the players orientation, well making the dummy walk in the actual direction that the player is moving in:

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local torso = character:WaitForChild("Torso")

local dummy = workspace:WaitForChild("Dummy")
local dummyHumanoid = dummy:WaitForChild("Humanoid")

game:GetService("RunService").Heartbeat:Connect(function()
	local moveDirection = humanoid.MoveDirection
	
	local moveSpeed = humanoid.WalkSpeed
	dummy:SetPrimaryPartCFrame(dummy.PrimaryPart.CFrame + moveDirection * moveSpeed * game:GetService("RunService").Heartbeat:Wait())

	local torsoLookVector = torso.CFrame.LookVector
	local position = dummy.PrimaryPart.Position
	dummy:SetPrimaryPartCFrame(CFrame.new(position, position + torsoLookVector))
end)

Thank you for all your help! :heart:

Edit: After more testing this actually didn’t work.

1 Like

You’re basically using my solution here. I would appreciate if you mark the correct post (mine) as the solution as you’re using my concept here.

You also don’t have to set the CFrame twice, you can do it in one script.

1 Like

I realized that setting the CFrame wont work, I want it so that the dummy can have collisions and if the player jumps on a part that the dummy doesn’t have under it, it will fall, etc, meaning I will most likely have to use “MoveTo()”.

you could just read the assemblylinearvelocity of the player’s humanoidrootpart and make the dummy’s :Move() function use that velocity

Then you could use LinearVelocity constraints set to plane mode! They respect collissions as well as gravity. You could read more about them on their documentation.

I’m kind of confused what you mean by this? Using:

game:GetService("RunService").Heartbeat:Connect(function()
	dummyHumanoid:Move(humanoidRootPart.AssemblyLinearVelocity, false)
end)

Doesn’t move the dummy at all.

use the assemblylinearvelocity of the player you’re tracking, when they move that gets updated on the server and the NPC should move. otherwise, if you want a quicker response time, give ownership of the NPC to the player you wish to mimic it’s movement and have the player in a localscript set the dummy’s :Move() to their own MoveDirection

1 Like

Thank you!
After some testing I’ve noticed this is a lot faster and more reliable then using linear velocities.
This is what I’ve ended up with:
Script in ServerScriptService:

local function setNetworkOwnerOfModel(model, networkOwner)
	for _, descendant in pairs(model:GetDescendants()) do
		if descendant:IsA("BasePart") then
			local success, errorReason = descendant:CanSetNetworkOwnership()
			if success then
				descendant:SetNetworkOwner(networkOwner)
			else
				error(errorReason)
			end
		end
	end
end

setNetworkOwnerOfModel(workspace:WaitForChild("Dummy"), game.Players:WaitForChild("DrDeadIy")) -- Temporary for testing

Script inside of StartCharacterScripts:

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local dummy = workspace:WaitForChild("Dummy")
local dummyHumanoid = dummy:WaitForChild("Humanoid")

humanoid.Jumping:Connect(function()
	dummyHumanoid.Jump = true
end)

game:GetService("RunService"):BindToRenderStep("move", Enum.RenderPriority.Character.Value + 1, function()
	dummyHumanoid:Move(humanoid.MoveDirection, false)
end)

This also works with animations! Here’s what it looks like in-game:

If anyone is wondering where how I got the dummy to have animations, theres plenty of scripts in the toolbox.
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.