Combine CFrame LookAt with CFrame Angles

Im trying to make this drone rotate smoothly toward the direction its looking while also having a tilt effect when its moving side to side.

RootPart.CFrame = CFrame.lookAt(RootPart.Position, RootPart.Position + plrCam.CFrame.LookVector)
local MoveDirection = RootPart.CFrame:VectorToObjectSpace(FlyVelocity.Velocity.Unit)
Tilt = Tilt:Lerp(CFrame.Angles(math.rad(MoveDirection.Z) * MaxTiltAngle, 0, math.rad(-MoveDirection.X) * MaxTiltAngle), 0.1 ^ (1 / (Delta * 60)))
RootJoint.C0 = RootC0 * Tilt

It does what I want it to do I just dont want it to change directions so suddenly. Is there a way I can combine the CFrame.lookAt and the CFrame.Angles in or to make all of its movement smooth.

The issue seems to be something else.

When I do it, the CFrame.lookAt doesn’t change directions suddenly adapting from my old tilt script which also modifies the C1 and now uses CFrame.lookAt.

The only bug is with humanoids as they don’t like the character being horizontal.

StarterCharacerScripts
local localPlayer = game:GetService("Players").LocalPlayer
local Character = localPlayer.Character or localPlayer.CharacterAdded:wait()
local lowerTorso = Character:WaitForChild("LowerTorso")
local humanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local normalize = Vector3.new(1,0,1)

local c1Store = lowerTorso.Root.C1

local tiltFactor = 2.5

local camera = Workspace.CurrentCamera
local ZEROVECTOR = Vector3.new(0,0,0)
game:GetService("RunService").RenderStepped:Connect(function()
	local movementVector = humanoidRootPart.Velocity*normalize*tiltFactor
	movementVector = (humanoidRootPart.CFrame-humanoidRootPart.CFrame.p):Inverse()*movementVector
	local x = math.rad(movementVector.X)
	local z = math.rad(movementVector.Z)

	local goalCFrame = CFrame.Angles(-z,0,x)
	humanoidRootPart.CFrame = CFrame.lookAt(ZEROVECTOR,camera.CFrame.LookVector*Vector3.new(1,0,1))+humanoidRootPart.Position
	lowerTorso.Root.C1 = lowerTorso.Root.C1:Lerp(goalCFrame,0.25)
end)

Make sure it’s in render stepped, as it needs to be in synced with camera movement. It feels like something is delaying the camera CFrame from updating and hence the sudden change in direction which is odd.

Also make sure to math.min the lerp alpha value to make sure it doesn’t go over the goal by 1 no matter what happens. It gets buggy if it does that.

0.1 ^ (1 / (Delta * 60)
math.min(0.1 ^ (1 / (Delta * 60), 1)
1 Like

My bad I probably should have gave more information. I have it so the direction only changes when i move the drone, which is what causes the sudden direction change, I just want to know how to make it do that smoothly whenever I move it instead of facing forward instantly.