Techniques For Having Groups Of Pets Follow Player

Some games have a mechanic in which groups of pets follow the player around, and work or play in the vicinity of the player. For example, one game has a bunch of bees following the player around. Other games use ground based pets which do a similar thing.

1. Following
What is the typical procedure used to get such groups to follow the player?

2. Individual Behavior
How do I get individual behavior in these groups? In many games, the pets seem to wander around and do their own thing, while staying in the vicinity of the player.

3. Ground Level
The terrain can have different elevations, so how do you determine the ground level for each pet?

4. Without Stressing Server
With 25 or more pets per player, I worry about stressing the server and introducing lag with too many moving pets. Is there a server friendly way to do this?

Thanks for any suggestions!

3 Likes

You can use;

  • Weld,
  • BodyMovers,
  • Constraints,

and a script to control it’s movement.

Using RNG to get pre-set behaviors.

Raycasting from the bottom side of the part or base from the player’s RootPart

Using the Client to control pet movement.

1 Like

For number one, you can just use CollectionService, put in a loop and have a spawn() function or ccoroutine where inside of it, it follows the player using :MoveTo. So each of the pets can try to move along simultaneously, if not just put a wait with a random number from 1 to 2

EDIT: Didn’t mean to reply to you. Sorry.

Using :MoveTo() would require the pets to be humanoids and 5-20 pets as humanoids using :MoveTo() wouldn’t be efficient I believe

I agree with the above however MoveTo is also a method for Models.

1 Like

Was confusing it with humanoid:MoveTo() I don’t think moving the model with MoveTo would be efficient either

You could also use SetPrimaryPartCFrame on models, or just anchor and TweenService the pet for a nice smooth effect (it would have to be of 1 union).

1 Like

with that I would recommend Tween Service since SetPrimaryPartCFrame can end up looking choppy so Tween 100% better

–SetPrimaryPartCFrame Example
https://gyazo.com/78b628540b50d0d234d32645c61148bf

If its anchored then less worries about physics?

Yeah I agree, also when you do make this @MapleMarvel you’re going to want to do all the tweening locally or else it will be just as choppy as SetPrimaryCFrame.

1 Like

That’s true anchoring would probably make it smoother.

1 Like

I don’t see any choppiness at all in some of these games that have groups of pets.

  • I don’t think Humanoid:MoveTo is used. This would not work with flying pets for example.

  • I don’t think SetPrimaryCFrame is used since it is too choppy.

  • I don’t think constraints are being used. An AlignPosition constraint would work, but always have the same offset to the player, which is not how pets in some of these games appear.

  • It could be a BodyMover which can handle following the player, and also some random individual movement. But I wonder if too many BodyMovers would cause lag.

  • Not sure about Tween Service. Do people really use it for such tasks?

1 Like

I am unsure of the performance overhead, but I’ve moved groups of things smoothly on the client with RunService:BindToRenderStep

RunService:BindToRenderStep("Control", Enum.RenderPriority.Character.Value+1, function()
	Rain.PrimaryPart.CFrame = CFrame.new(Player.Character.HumanoidRootPart.Position + Vector3.new(0,50,0))
end)

Unfortunately, it has to be done every frame, or the result is jittery. I used this method for making rain particles follow the player when attempting to create a stormy atmosphere.

It worked for my use, it might work for controlling the group of pets for you - but you’d still need to figure out individual movements within the group.

1 Like