How do games achieve this tween animation?

Some games, like this one, have this effect for loading items into the game when they are purchased:

I think it’s quite neat, and I would like to have this option for my own game, where I “just” have this type of animation for buying things

How would I get the animation from the first video?

1 Like

As i see here, every descendants of the model are tweening into their start position. Before tweening, save every descendants’ CFrame, then move them somewhere, tween them with goal being the start CFrame.

2 Likes

I guess store the original CFrame of the object and make a new one with a randomised rotation and position, like a maximum of 50 studs from the original position. Then set the objects position to that and tween it to the original position.

2 Likes

That’s what I was thinking of well. What would the code even look like?

I wrote a quick function to replicate this kind of effect, I also added a transparency tween so it doesn’t look weird, you can remove it if you like:

local TweenService = game:GetService("TweenService")

local TweenInf = TweenInfo.new(1)

function TweenAnimation(Part : BasePart) : ()
	local BaseCFrame = Part.CFrame
	local RandomisedCFrame = CFrame.new(
		BaseCFrame.Position.X + math.random(-15,15),
		BaseCFrame.Position.Y + math.random(1,15),
		BaseCFrame.Position.Z + math.random(-15,15)) *
		CFrame.Angles(
			math.rad(math.random(-45,180)),
			math.rad(math.random(-45,180)),
			math.rad(math.random(-45,180)))
	
	
	Part.Transparency = 1
	Part.CanCollide = false
	Part.CFrame = RandomisedCFrame
	
	TweenService:Create(Part, TweenInf, {CFrame = BaseCFrame}):Play()
	TweenService:Create(Part, TweenInf, {Transparency = 0}):Play()
	Part.CanCollide = true
end

Now you can use a for loop to loop through your model/object to get your desired building effect.

2 Likes

This came out beautifully

Thank you so much!

2 Likes