Looking to figure out how to make companion movement similar to JJS Rika/Divine Dog

Uploaded two videos for reference on what I’m talking about, but what methods could you go about to make a companion model move in sync with the player but also maintain a specific position and forward orientation at their side? I’m trying to do this with a normal humanoid R15 rig so it would likely be a little simpler than using a custom model.

I’ve tried attaching a part at my desired position to the player with a WeldConstraint and then having the rig use Humanoid:MoveTo(ThePartInQuestion) but the rig tends to lag behind towards that point rather than snapping around like Divine Dog and Rika are in JJS. Anyone have any clues or tips on how to accomplish this effect/what parts of the documentation to look at?

My first inclination is towards some CFrame magic but I’ve also tested linking a constant CFrame refresh to RunService.Heartbeat but I imagine that will be laggy for the game I’m gonna use this in. Currently the movement code is in a server script to make sure movement is shown on all clients and there’s no weird desync. I’m trying to figure this out for my character’s power visuals on a RP game and I don’t want to lag out other people for this little bit.


EDIT: As a further note, I’ve also tried controlling the second rig with a separate input local script to have it move in tandem with the character using Humanoid:Move(). This has yielded the closest result so far but I am still lost as to how to have the secondary rig positioned and oriented in the same place relative to mine.

1 Like

I would assume they anchored the root part of the rig and tween it around constantly based on the cframe of the player (with some modifications, if ur ragdolled ofc).

Doesn’t seem like a Humanoid:Move() type of thing based on how it rotates

If you’re concerned about lag for constant updating of the cframe, either:

  • use a variable to track the previous CFrame (of the player character) and only update it when update the companions cf when that changes
  • make it so the companion is rendered on every client instead of server (this is the better option imo, but idk 100% how that game is played so can’t say for sure)

Use a raycast to see where the Y of the comapnion would be

lmk if u need clarifications

I’ll try to develop this and see how it goes. Unfortunately I can’t make the companion completely client sided since I’m not a dev for the game; I’m simply making a morph and packaging it as an .rbxm to send over and import and asking them to add something to StarterPlayerScripts would be asking too much. Even for things I link to Heartbeat I disconnect when it’s not in use.

Could you elaborate on what you mean by using a variable to track the previous CFrame? The character is moving around all the time and the companion is following so I imagine that value is always changing, so how would this save performance?

Is this similar to the kind of movement you are looking for?

If so, the code I used to achieve this affect is below. It essentially lerps the object to the desired position every frame (ran on the client). Please keep in mind this code was written a couple years ago (and I don’t even think I wrote all of it), but it works for me and I hope you can repurpose it to your own needs.


local attach = char.PrimaryPart.GearPosAttachment -- desired position expressed as an attachment object
local timePassed  = 0
local origCFrame = gear.CFrame
local currentAngle = gear.CFrame - gear.CFrame.p
local desiredAngle = (attach.WorldCFrame - attach.WorldCFrame.p) * CFrame.Angles(0, math.rad(45), 0)

conn = runService.Heartbeat:Connect(function(delta)
	timePassed += delta
	local alpha = math.min(timePassed/total, 1)
		
	gear.CFrame = CFrame.new(gear.Position:Lerp(attach.WorldPosition, (20 * timeMultiplier) * delta)) * currentAngle:Lerp(desiredAngle, alpha)
		
		
end)

Good luck!

This is very similar to the effect I want thank you for providing it! I’ll experiment with it while I also check out the other methods provided! My main concern now is figuring out how to make it more performance friendly since it needs to run on the server instead of the client just on the basis of I’m sending a morph and not actually a dev for the game I’m gonna use this in.

Sending a morph? What does that mean?

When I was coding the wheel thingy, I was aware of performance issues - so I sent an event to every player to create and animate the wheel so it is run on the client AND everyone can see it.

It would only save performance in the client-side scenario since the server wouldn’t have to send updates to the client if the player is standing still and the rig is not moving. And yeah, I agree that doing that if it’s only server-based wouldn’t help much.

I highly suggest you talk to whoever you’re working with to let you set it up so it’s rendered on the client because in a scenario where there are a lot of players, it will get laggy with the server trying to update a bunch of those rigs at once.