How To Get The CFrame Between Two Parts (Like :Lerp)

Hello, I’m trying to tween a cframe to a certain spot in between two parts, but I don’t want to use :Lerp() because there is no option for easing style or time, so I’d rather use tween service.

The problem is, I’m trying to set the “CFrame” property of the tween to a spot in between the goal part and the part I am trying to tween, but I’m not sure how to do so.

1 Like

do you mean like the midpoint?

Any point between 0 and 1.

minimumchars

no no i mean, do you want to get the midpoint of the 2 cframes?

oh wait ik what you mean now

minin

You could use lerp, get its halfway point, and then use it as your tween goal

Does :Lerp() return the CFrame between the two points and the given number?

Use the :Lerp(delta) function and use the return of the function as the tween goal

For example, if alpha = .15, would it return the CFrame at that point in between the two parts?

yes very true super true ofcourse

Alright, I’m gonna go ahead and try this out.

Yea, it does. The thing is you have to save the cframe so the parts Cframe doesn’t get affected

So if I put it in to a seperate function and return part.CFrame:Lerp(goalCFrame, alpha) It’ll return the CFrame value?

Yeah, it will. Don’t forget alpha is between 0 to 1 btw

Edit: You don’t need a function for this. You can do it like this:

local Alpha = 0.5

game:GetService("TweenService"):Create(
	Part1,
	TweenInfo.new(1), 
	{CFrame = Part1.CFrame:Lerp(Part2.CFrame, Alpha)}
)

Oh got it, will try this. Just finishing up some code before. I’ll let you know if all works well.

1 Like

This works, thank you!

minimum

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