Optimize Pet Follow?

How are you using the align position?
You should have it aligning a part from the pet that has all the other parts welded to it. Having a humanoid shouldn’t affect this as I’ve used align position on players in my past projects.

When I tried it I used attachments connected to the hrp of the player and set the align position to go to it. You said i need parts, does it make a difference?

Attachments are fine. Is the pet welded correctly?

oh wqait its wokring, but the pet is like laggin behind really badly why is that?

wait now its like glued to the attachemtn i want it to slowly get there

i thgink i need to change this settings, what is best?
image

just play around with it and find whats best, just make sure rigidity enabled isnt on

ive been trying to figure it out for a while, do you mind tell me how you made yours in the past if you even have?

I haven’t made a pet follow system but just opened up studio and used these settings and it worked pretty smooth:
image

i have the same settings, but my pet is acting likes its welded to the attachment instead of smoothly going to it. can i not do that with align position?

that’s strange, is yours set up similarly to this:
image

yes its exactly like that, but the pet isnt inside the player its in a folder in workerspace

could you show me the code? There might be something affecting it

	local attach = plr.Character.PrimaryPart["workerAttach" .. workerNum]
	worker.PrimaryPart.AlignPosition.Attachment1 = attach
	worker.PrimaryPart.AlignOrientation.Attachment1 = attach
	
	delay(1, function()
		worker.PrimaryPart:SetNetworkOwner(plr)
	end)

it just sets the attachments and then sets the network ownership to the player, if i dont set it to the player the pet lags behind a lot

Ye, I don’t know what’s wrong, I suggest playing around with different stuff to see if it fixes it or just try a new method

its because of the repeated math calculations, try to find a way to lower the math calculations done every frame, or delete the script and redo it. I would make one while loop with an interval of .1 seconds using task.wait() and it assigns a local variable pos thats equal to the players humanoid root part, then it checks if the Players humanoidrootpart position is the same as pos and if its not make a tween to go to the position next to the player. do the tweening in a server script if your game is multiplayer, else, make it in a local script.

or just use a weldconstraint lol.

this article is for optimizations you should check it out
+ pet follow optimizations was written in the article

wow this is like perfect thank you

1 Like

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