How to "overlay"/combine tweens?

I’ve recently stumbled across this effect I saw in a gameplay video for Pokemon Brick Bronze where they seemingly 1. tween the rotation of a model 2. tween a separate model at the same time with the first connected to it however still rotating, so that there is a whole hierarchy of rotations combining to connected objects?? to give a visual explanation, here is the video I saw this effect being used in, where all the faces of a cube get tweened at once to rotate from a flat net , to a complete cube in one full motion (and vice versa), as opposed to each model being tweened separately, welding onto the next moving model that will be tweened, etc.

(pasting the video at a certain timestamp doesnt seem to be working, skip to 6:00)

how would I replicate this effect, especially with models instead of simple BaseParts?

bumping this post because I forgot how competitive this category is for getting solutions :sweat_smile: is this the wrong category to place this in? i doubt this is in the wrong one but lmk if thats why I havent gotten a response yet

You don’t have to use tweenservice directly. You can attach some code to renderstep that manages the tweens yourself. This will allow you to implement custom rules into it such as making tweens relative to another part. Tweenservice will let you still use the tween types it provides by using :GetValue() (or whatever it was called) though.

This is basically creating your own more customizable version of tweenService by handling the movement yourself every frame.

yeah, I kinda thought it may come to just remaking tween services myself via RunService even when i didnt really want it to :sweat_smile: i’ll try return back soon with a snippet of code i’ll myself for this purpose but im not really that good with CFrames so i’ll leave this post open if anyone wants to let me know if its most likely unoptimized

@tlr22 finally done :face_exhaling:

local function RotateAroundPivotNew(Hinge: CFrame, ConnectFrom: string, alpha: number): CFrame
	ConnectFrom = string.lower(ConnectFrom)
	alpha = math.clamp(alpha, 0, 1)

	local PivotFromTop = if string.sub(ConnectFrom, 1, 1) == "t" then 1 else -1
	local PivotSide, PivotSideX, PivotSideZ = string.sub(ConnectFrom, 2), 0, -40
	local RotX, RotZ = math.rad(alpha * 90) * PivotFromTop, 0
	
	if PivotSide == "left" then
		PivotSideX = PivotSideZ		PivotSideZ = 0
		RotZ = -RotX RotX = 0
	elseif PivotSide == "right" then
		PivotSideX =  -PivotSideZ	PivotSideZ = 0
		RotZ = RotX  RotX = 0
	elseif PivotSide == "back" then
		PivotSideZ *= -1 RotX *= -1
	end
	
	return Hinge * CFrame.new(PivotSideX, 0.5 * PivotFromTop, PivotSideZ)
		* CFrame.Angles(RotX, 0, RotZ) * CFrame.new(PivotSideX, 0.5 * -PivotFromTop, PivotSideZ)
end

i’ll be using this function to get where each face/side/wall of the cube should be, to explain how it works/my thought process; each face of the cube will be pivoting as if a door along an anchored hinge, and the alpha parameter is for how far into the “tween” its gotten. for example, with an alpha value of 0.5 and “TFront” as the ConnectFrom parameter to signify which edge of the cube it will pivot around, it will return a CFrame that can be given back to the cube face, where its rotated halfway on the top-front edge of the “hinging” part.

(looking at this screenshot made me realise i practically just remade the Archimedes plugin but wtv lol)

(this is the line i was using to apply the cframe to these two test parts)

workspace.TestDoor.CFrame = RotateAroundPivotNew(workspace.TestHinge.CFrame, "TFront", .5)

for anyone who may use my function, the size of each cube face is hardcoded into the function based on my cube im using so i dont really see a use of adding a parameter/global variable to change the final calculation, so like you said, i’ll be using TweenService:GetValue() and basically just plugging that in for the alpha value of each cube face and that should be it :+1::+1:

my main slight worry is the last line where im calculating the final CFrame and how im multiplying 4 CFrames in each function call for (at most) 5 cube faces every frame, so will this be a resource intensive process? is there some redundancies in my CFrame calculation that i can remove to optimise the function? and should I run this “tween” on the server, or fire out to all clients to make them do the process clientside if it would noticeably make it look smoother?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.