Make a rig follow the player

I am trying to make a rig follow the player from behind. What I made works well in one direction, but once you start rotating, it gets really messed up.
This is what happens when you rotate the character.
I am trying to make it stay behind the player, even when it rotates.

I have tried to find some articles about this, but I’ve never found any who’d help me in this specific situation.

The rig’s HumanoidRootPart has the BodyPosition and BodyGyro, and all the parts are welded.
image

(This is the code inside the script, if it helps)

while wait(.1) do
script.Parent.BodyPosition.Position = game.Workspace.Player.HumanoidRootPart.Position - game.Workspace.Player.HumanoidRootPart.CFrame.LookVector - Vector3.new(-2,0,2)
script.Parent.BodyGyro.CFrame = game.Workspace.Player.HumanoidRootPart.CFrame
end

How could I make it stay behind the player, no matter how it rotates?
Thanks!

3 Likes

This looks like a proper rig setup for a humanoid so why not use one? You could just use :WalkTo from there.

I’m planning on making it animate like it’s floating, not walking.

Interesting. This topic might be useful. You would want to consider wrapping this in a RunService.Heartbeat connection as well instead of an infinite loop.

Also, I wanted to point out that you can’t assign CFrame values to BodyMovers. Only position. You can get a Vector3 value from a CFrame by simply doing CFrame.Position.

1 Like

Thanks for the help!
But is there any other way to do it?
Like, is there a way for only one bodyPosition make the rig stay behind the player?

Also, how could I fix the problem in the video?

Edit: I also want to use bodyPosition because I like the way the rig smoothly moves behind the players. Also the heartbeat thing helped a lot!

In your case, AlignPosition would be a better choice than BodyPosition. Create a constraint, parent it to the HumanoidRootPart of the player’s character and change its position so it’s around where you’d want the second character to be located. Create a second constraint, parent it to the second character’s HumanoidRootPart. Create the AlignPosition constraint, parent it to one of the characters’ HumanoidRootParts and apply the Attachment0 and Attachment1 properties.

One thing to note is that the second character might get stuck on obstacles, so you’ll have to check each frame whether it is too far away and fix its location if it’s too far away.

1 Like

You can’t just use PathfindingService for this?

One thing to note is that the second character might get stuck on obstacles, so you’ll have to check each frame whether it is too far away and fix its location if it’s too far away.

The second character is CanCollide = false, so it shouldn’t be a problem.

Also, for the Constraint, what should I use? WeldConstraints, attachments?

I don’t want the second character to walk, I want it to be kind of stuck to the player in that position. Also, the second character doesn’t have humanoid.

As I said, AlignPosition. aaaaa

I created 2 attachments, one on the player and one on the second character, then set the attachment0 and attachment1 of the AlignPosition to them and it still didn’t work, the character just falls to the ground.
Do I need to script or anchor something?

Sorry if I’m missing something obvious, these things are a real pain for me.

The force might be too weak, can you screenshot the current setup with the constraint selected?

Try switching the Attachment0 and Attachment1 properties.

Did that, still doesn’t work.
The parts just stay where they were, ignoring the alignment position.
This is a gif of what happens.

Is there a BodyPosition mover in one of them? Did you unanchor the one you want to move?

1 Like

Yes, it’s unanchored and there is no bodyPosition mover in any of them.

Can you export them as a model? This is really strange.

1 Like

Here it is.
PlayerAndRig.rbxm (7.4 KB)

One of the Rig’s parts is anchored. Select the model and press Anchor twice in Home tab.

1 Like