How did this game make their pets so smooth moving and lively?

https://gyazo.com/887d1a5b1feaa74104f84ddfbf1758bb

In this gif you can see those pets are moving relative to the character but they also have the added bobbing effect and they move very smoothly (not like being welded to the character). How could I replicate this bobbing effect?

6 Likes

Take a look at Roblox’s Tween Service.

1 Like

Ok what do I do with tweenservice to make the pet so “bouncy” and life-like. Its not like a cube thats just moving around with tweenservice or being welded to the character. The choco bunny bet I had also bounces up and down as it moves.

That simply requires an animation that likely uses a quadratic easing style.

All it takes is some MoveTo magic with humanoids or the tween service to get to the specified offset position.

1 Like

They appear to be moving up and down, but also just tilting back and forth. The tweenservice will do both of those with mathematical graduations. Heheh, like snorebear just said.

3 Likes

If you make all of the highly visual aspects of your game (like animated objects and projectiles) animated completely client-sided, they will always look very smooth. Those are the perks of offloading animations/visuals to the clients instead of doing it all on the server or the network owner of the pets.

Alright i’ll do my effects client side. Problem is that I still have no idea how to replicate the motion of the pet. Somehow i’m supposed to use tweenservice and moveto magic with humanoids :frowning: .

You could animate the pets entirely by cframe if you really wanted to by using lerp and sine waves. Also, the pets dont have to be perfectly accurate on all systems. They just need to be roughly in the same place.

1 Like

Animating entirely by cframe sounds good. But how :frowning: Theres like a tilt and bobbing motion plus the pet follows the motion of the character. I cannot fathom how to apply all three of these at once. If I weld the pet then it can’t do the bobbing.

local c = cos(2 * time() + i)
pet.CFrame = pet.CFrame:Lerp(
    attachCFrame * CFrame.Angles(-c, 0, 0) + Vector3.new(0, c * 2, 0),
    0.1
)

You can also just make a repeating / looping tween or something. Whatever works really

3 Likes

My brain is currently too small to understand CFrame:Lerp im gonna go make it bigger and report back

Wait whats attachCFrame supposed to be

It interpolates from one CFrame to the other by using a percentage.
You can visualize it by taking a point and at 0% its at the start of a line, at 100% its at the end of the line, and at 50% its halfway between the start and end.

local function lerp(a,b,c) return a + (b - a) * c end

print(lerp(5, 10, 0)) --5
print(lerp(5, 10, 1)) --10
print(lerp(5, 10, 0.5)) --7.5
1 Like

is attachCframe the rootrigattachment?

It is wherever the pet should attach to. Usually, some point around the player.
https://i.gyazo.com/5fd902a2f7e811874cd79a949edaacbd.mp4

ok so lemme get this straight

I wanna weld some part to the character, this part’s cframe is gonna be attachCFrame. Then I lerp from that cframe according to the cosine function thingy you wrote. Idk what the i variable is for

The i variable is just for the index of the pet, as you will probably do this for all pets. This will make them have a sort of wave-like motion because each pet will be offsetted.

https://gyazo.com/88d781647d639ec7b9276a13dfb6e783

yooo i got something going on!

try using sin() instead of cos() for the tilting and add like 0.1 to it so sin(2 * time() + i + 0.1)

1 Like

I would use RenderStepped with a lerp instead of tweenservice. Using the step argument. Something like

game:GetService("RunService").RenderStepped:Connect(function(Step) 
      Pet.CFrame = Pet.CFrame:Lerp(Base.CFrame * CFrame.new(0, 0.66 * math.sin(tick()), 0), Step) 
end)
3 Likes

isnt that the same thing just slightly shifted in the x direction