How can I lerp CFrame.lookAt()? This question sounds stupid. But can I do it? Or is there an alternative way?
1 Like
You may just be able to get the CFrame
that was made from LookAt
and Lerp it from there, but for TweenService
, I think you can do this:
TweenService:Create(Instance, Info, {CFrame = CFrame.lookAt(Pos, OtherPos)}):Play()
You can lerp between two CFrame directly so all you need to do is construct one using lookAt
and call Lerp
from the other.
local originCFrame = ... -- your starting CFrame
local targetCFrame = CFrame.lookAt(a, b) -- your lookAt call
local lerpedCFrame = originCFrame:Lerp(targetCFrame, i)
1 Like
What do you want to achieve? If you want to lerp CFrame.lookAt() use the method shown by @woot3.
If you only want to lerp position or direction you can do this:
local function lerp(a, b, c)
return a + (b - a) * c
end
local cfr = -- path to your CFrame
local pos = Vector3.new(0, 5, 0)
local target_dir = Vector3.new(0, 10, 0)
cfr = CFrame.new(pos, lerp(Vector3.new(), target_dir, alpha))
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.