Properly animate a floating pet

Hi! I want to make an animated float system for pets, like a bubble one, smooth and nice.

This is how it stays close to me, server-sided:

while wait() do
	
	local vector3 = game.ServerStorage.Pets.Pos[script.Pos.Value].Value
	local pos = player.Character.HumanoidRootPart.CFrame * CFrame.new(vector3)

	bodygyro.CFrame = player.Character.HumanoidRootPart.CFrame
	bodyposition.Position = Vector3.new(pos.x, pos.y, pos.z)
	
end

So I use BodyGyro and BodyPos and I don’t know if I need some localsided renderstepped floating, or use tweens, or Animations.

Neither of those ways worked well or not at all. This is the closest I have:

https://i.gyazo.com/d5b04048eb99b9c200222aebe4451787.mp4

3 Likes

If I understand you correct, you want it to have a float effect so it goes up and down a little?

2 Likes

thats correct :slight_smile: and maybe some other little gyro effects

2 Likes

I would recommend you to use BodyPosition and BodyGyros in the client side, because otherwise the server can have performance issues, also you should use RenderStepped, as the while loop isn’t really ideal for it.

1 Like

I suppose having a loop that is changing the y axis constantly with ±0.01 would be the easiest way. You could just make a variable and loop through it. When it becomes 1, just make it subtract til it reaches 0 and vice versa. Then just add it to the y axis. That should be the easiest way (Not sure if it’s the cleanest way though)

1 Like

Ok got it. What you say is for my pets, but how should I do with other people’s pets? I need like one script with one renderstepped for each pet in the game, or just one renderstepped with a for loop to do it with all the pets?

What I mean actually is each clients pets are handled by them, in the client side scripts. And yes all pets of that player in one RenderStepped should work.

But how can I see the movement of the other pets if they are being handled by each client?

1 Like