Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is it possible to lerp a model? If so, how?

What I want to happen is when a character presses 'M' then a model will slowly come up from the ground next to the character. I can do the pressing M part but I'm not sure how to move the model smoothly.

2 answers

✓ Accepted answer

Basic lerp methods:

cframeoffset = CFrame.new()

game:GetService("RunService").RenderStepped:Connect(function()
	cframeoffset = cframeoffset:lerp(target CFrame, alpha) --when approaching its target slows down, e.g: 0, 0.5, 0.75, 0.875 etc...
	cframeoffset = start CFrame:lerp(target CFrame, alpha) --travels at a steady speed, e.g: 0.1, 0.2, 0.3, 0.4 etc...
end)

And to lerp the model:

local model = path.to.model
game:GetService("RunService").RenderStepped:Connect(function()
	--method you used to set the cframe
	model:SetPrimaryPartCFrame(cframeoffset)
end)

I hope this helps.

4 comments

0

Yeah, I haven't started lerping because when I spawn the model, it spawns sideways. I posted another question about that, but no one has answered it yet.

0

just use angles to rotate the model, cf * CFrame.Angles(rad(n), rad(n), rad(n))

0

Pretty sure I did that and it didn't work.

0

Okay the orientation worked. Decided not to lerp though.

This discussion is preserved as it was. New answers, comments, and votes are closed.