How does Pet Simulator do it?

Hello everyone

I wanted to share here what I have been wondering for a long time because I could not find a correct result despite a little research…

When you open an egg in Pet Simulator 99, the pet you hatch first stands next to you for a few seconds and then animatedly approaches your camera. What is the most logical approach for this thing? How can it be done? Can you show an example or can you share a source?


video is taken from: https://www.youtube.com/watch?v=MYsMCJmC92U

5 Likes

The pets are likely inside a viewport frame, and just use a tween to move infront of the camera.

3 Likes

I would guess they are lerping each pet to a pre-defined object-space CFrame in front of the camera. Since the animation stays with the camera when it is moving, I don’t think tween will do what you want so you’ll need to write a lerp function and run it every frame to achieve the effect.

3 Likes

I suppose they created an Invisibile Frame that cover the whole screen, which contains Gridlayout or ListLayout and smaller frames based on the amount of pets they are collecting. Then get the world position using Camera:ScreenPointToRay() with the smaller frames AbsolutePosition as input. After that, you set the pet model CFrame with UnitRay.Position returned from the Camera:ScreenPointToRay() and rotate the pet with UnitRay.Direction or “Camera.CFrame:ToEulerAnglesYXZ()”

8 Likes

I doubt they are using viewport frames but instead just have each pet created on the client. That way the pets are actually being moved in front of the camera every frame while other clients delete others’ newly hatched pets. You could make UI for every pet hatched like @idkhowtomakeusername said, or calculate the position of each tile by dividing the camera.ViewportSize into partitions.

2 Likes

Adding on to this, you can tell this is what’s done because the models don’t have the outline artifact of viewport frames.

This is what everyone did before viewport frames.

1 Like

The way it works is that the pets positions are constantly updated to the players camera through a runservice loop probably. You may want to play around with it but yea.