Pet Positioning


How would i achieve this pet positioning? I’ve tried something but im just so bad at math.
image

3 Likes

First you’ll need a path finding system. I recommend using SimplePath. Once you have a path finding system, you’ll need to create a loop that continuously sets the pets goal position to be the HumanoidRootPart. And finally you should add a Vector3 value to modify the HumanoidRootPart’s position. Example:

GoalPosition = player.Character.HumanoidRootPart.Position + Vector3.new(3,3,3)
1 Like

If you want the cframe of the pets to be behind the player and also on the floor w/ height then here’s a simple function that based on the root’s coordinates and the constants for the pets. (after just interpolate or what the post above said to pathfind the pets to the respective locations.)

function calc(root: Instance, pet: Model)
	local cframe = root.CFrame
	
	local distance_away = 7
	local height = 1 --replace with any height you want for the pet
	
	local coordinate = Vector3.new(cframe.X, height, cframe.Z)
	
	local offset = Vector3.zero --replace with pet's order offset
	
	local direction = Vector3.zAxis * distance_away
	
	--pet:PivotTo(result)
	return CFrame.new(coordinate) * cframe.Rotation * CFrame.new(direction + offset)
end
1 Like

Assuming you can’t pick your own layouts in-game, the positioning will depend on the amount of pets you have. It means that certain amount of pets (like 5 and 3 as seen in the screenshots) have a custom arrangement, and every other amount is automatically organized into some pattern (like a circle).

Actually implementing them is the hard part, but I figure there’s more than enough resources for doing this. As an example, How to create a pet system that dynamically generates positions.

If you can’t find these posts with the DevForum’s search engine (because it SUCKS), you can always use Google or DuckDuckGo, like so: Google Search.

Good luck!

2 Likes

You actually don’t need any pathfinding at all, just pure CFrame manipulation + maybe some raycasts with some lerp to smooth it out

1 Like

Pathfinding systems prevent the pet from getting stuck behind obstacles and are also quite easy to implement. Roblox has a built-in pathfinding system, and there are many community-built ones on the devforum. Raycasts and CFrame manipulation are unnecessary.

1 Like

While pathfinding may be useful for getting pets unstuck, CFrame manipulation is necessary to get it working, unless the OP doesn’t want a structured pet formation (which i’m pretty sure the OP does want it). Imo, pathfinding is optional (i suppose its quite computationally expensive for hundreds of pets as well)

also by CFrame manipulation, i mean just doing some cframe math

1 Like