Pathfinding pet system

Hey! So i’m currently making a pet system for a game and i’m unsure how to make some parts of it! I’m want to use a pathfinding system similar to games like Adopt Me and Overlook Bay! However I am unsure on a few things!

  • How do I keep recalculating the path to follow the player? I’ve had a problem where it will follow exactly where the player has been but i want it to calculate new routes constantly so it can find the shortest route back to the player!
  • How can i make the pet stand behind the player when something is within a few studs ahead of the player!

Thank you! Id be grateful for some help!

Why not just give it a different collision group and make it move towards the player’s humaniodrootpart but a bit further away? It’s easier, less taxing overall and shouldn’t bug as much (eg. if the player climbs a tower, etc.).

1 Like

Huh?? I don’t really understand?? It doesn’t really answer my questions. If you mean the thing where it goes behind the player thats just for realism and uniqueness!

I dont think they use pathfinding service. I don’t see why you need to use pathfinding. You can just use BodyPosition and BodyGyro

1 Like

Step 1.) Search up “How to make pets in Roblox Studio”

Step 2.) Find the part of the video that explains pets following you and make sure it’s NOT pathfinding, there are better ways of doing so.

Step 3.) Come back here if you’re having any bugs then I can help you.

Sorry if I came off as rude in this post, I’m just joking around. On a serious note, please do not use pathfinding, I’ve never really worked with pets or anything like that, but I’m pretty sure you can do things like welds, or anything that has it attached to the player while having a sort of natural movement.

1 Like

I am currently and it just looks unrealistic as the way that the pets turns is so smooth and fake. Heres a video of them! https://gyazo.com/44833a5ac0a792ebbb9a4c3cbad820af Do you see when i turn the corner it looks weird.

Here is my BodyGyro properties:

local BodyGyro = Instance.new("BodyGyro")
	BodyGyro.CFrame = PetObj["Base"].CFrame
	BodyGyro.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
	BodyGyro.Parent = PetObj["Base"]

and here is the part where i update the gyro and that:

function UpdateTween()
	FollowTween = game.TweenService:Create(PetObj["Base"]["BodyPosition"], TweenInfo.new(0.25, Enum.EasingStyle.Linear), {Position = Player.Character["HumanoidRootPart"].CFrame.p - Vector3.new(-2, 0, -2)})
	TurnTween = game.TweenService:Create(PetObj["Base"]["BodyGyro"], TweenInfo.new(0.25, Enum.EasingStyle.Linear), {CFrame = CFrame.new(PetObj["Base"].CFrame.p, Vector3.new(Player.Character["HumanoidRootPart"].Position.X, PetObj["Base"].Position.Y, Player.Character["HumanoidRootPart"].Position.Z))})
end

function UpdatePetObj()
	if (Player.Character["HumanoidRootPart"].Velocity).Magnitude > 6 then
		if (Player.Character["HumanoidRootPart"].CFrame.p - PetObj["Base"].CFrame.p).Magnitude > Distance * 1.5 then
			FollowTween:Play()
			TurnTween:Play()
		end
	end

I used this for help: Pet Follower v.02

Why did you use TweenService on BodyPosition and BodyGyro? I’ve tried it without TweenService and it’s already tweening by itself. You can also change the speed using a property called D or Dampening.