Pet system with character does not jump

Well, im trying to make something like a pet system but with characters, just like almost all anime games. I did some research and i found that one of the best ways of doing this is by using :Lerp(), so i created a module that executes a function that lerps the pet character CFrame with my CFrame, so the character can walk to right next to me. I did some tests in a empty baseplate and it worked well, but when i tried in the game, for some reason that i don’t know why, the character does not really follow me. It is hard to explain, so i recorded a video showing what i want, and what is happening.

Here is the video (hosted in streamable):
https://streamable.com/z3pnyz

I’ve already tried to use the same models, change some humanoid priorities, change character mass, and it does not work. (both models in both places are the same)

Does anyone know why is this happening?

Here is the module source code:

local module = {}

local RunService = game:GetService("RunService")

function module:SetFollowing(Player, UnitModel)

	UnitModel:ScaleTo(.5)

	UnitModel.Parent = workspace
	local Offset = CFrame.new(-4,-1.5,4)
	local PrimaryPart = UnitModel:WaitForChild("HumanoidRootPart")
	local AnimationID = "http://www.roblox.com/asset/?id=180426354"
	local AnimationID2 = "http://www.roblox.com/asset/?id=16800682361"
	local Humanoid = Player.Character.Humanoid
	local Humanoid2 = UnitModel.Humanoid
	local Smooth = .025
	local Anim = Instance.new("Animation")
	Anim.AnimationId = AnimationID
	local Anim2 = Instance.new("Animation")
	Anim2.AnimationId = AnimationID2
	local Track = Humanoid2:LoadAnimation(Anim)
	local Track2 = Humanoid2:LoadAnimation(Anim2)


	local function FollowLoop()


		if (UnitModel.HumanoidRootPart.Position - Player.Character.HumanoidRootPart.Position).magnitude <= 50 then
			Smooth = .025
			PrimaryPart.CFrame = PrimaryPart.CFrame:Lerp(Player.Character.HumanoidRootPart.CFrame * Offset, Smooth)
		else
			Smooth = .075
			PrimaryPart.CFrame = PrimaryPart.CFrame:Lerp(Player.Character.HumanoidRootPart.CFrame * Offset, Smooth)
		end


		if Player.Character.HumanoidRootPart.AssemblyLinearVelocity.Magnitude > 1 then
			if not Track.IsPlaying then
				Smooth = .025
				Track:Play()

				if Track2.IsPlaying then
					print('stop track 2')
					Track2:Stop()
				end
			end
		elseif Player.Character.HumanoidRootPart.AssemblyLinearVelocity.Magnitude < 1 then
			if Track.IsPlaying then
				Track:Stop()
				Smooth = .075

				if not Track2.IsPlaying then
					print('play track 2')
					Track2:Play()
				end
			end
		end
	end

	PrimaryPart.CFrame = Player.Character:WaitForChild("HumanoidRootPart").CFrame * Offset

	local Connection = RunService.RenderStepped:Connect(FollowLoop)

	return Connection
end

function module:UnsetFollowing(Connection)
	Connection:Disconnect()
end

return module
2 Likes

are you sure that specific model in the video was anchored

1 Like

I don’t want to anchor it because i want to play the animations, but yeah both them are not anchored. Both are not anchored

1 Like

I’m a bit confused on what you exactly want. Are you wanting how the game at the beginning of the video has it? Where the NPC’s position is always on the ground regardless of how high the player is positioned upwards?

1 Like

Sorry for not explaining that well. But yes, i want the NPC position to be always next to me, regardless of how high i am.

2 Likes