I am trying to lerp 2 rotations to create a smooth turn, however the two values are different for some reason. Let me show you:
I made 2 values in a table store 2 CFrames:
EnemyData.OldCFrame = EnemyData.CFrame
EnemyData.CFrame = GetNode(EnemyData.Node, EnemyData.Path).CFrame:ToWorldSpace(CFrame.new(0, 0, (EnemyData.CFrame.Position - (GetNode(EnemyData.Node, EnemyData.Path).Position)).Magnitude - (EnemyData.Speed * OverallDeltaTime))) * CFrameAngles(EnemyData)
The CFrameAngles function being this:
local function CFrameAngles(EnemyData)
return CFrame.fromOrientation(CFrame.new(GetNode(EnemyData.Node - 1, EnemyData.Path, true).Position, GetNode(EnemyData.Node, EnemyData.Path).Position):ToOrientation(),
select(2, CFrame.new(GetNode(EnemyData.Node - 1, EnemyData.Path, true).Position, GetNode(EnemyData.Node, EnemyData.Path).Position):ToOrientation()),
select(3, CFrame.new(GetNode(EnemyData.Node - 1, EnemyData.Path, true).Position, GetNode(EnemyData.Node, EnemyData.Path).Position):ToOrientation())
)
end
However, when referencing them again, using this code, this is the ouput:
CFrame.fromOrientation(
Lerp(EnemyData.OldCFrame:ToOrientation(), EnemyData.CFrame:ToOrientation(), EnemyData.DeltaTimeAdded / EnemyData.OverallDeltaTime),
Lerp(select(2, EnemyData.OldCFrame:ToOrientation()), select(2, EnemyData.CFrame:ToOrientation()), EnemyData.DeltaTimeAdded / EnemyData.OverallDeltaTime),
Lerp(select(3, EnemyData.OldCFrame:ToOrientation()), select(3, EnemyData.CFrame:ToOrientation()), EnemyData.DeltaTimeAdded / EnemyData.OverallDeltaTime))
However, this does not give me the desired result, making the part face the wrong way
(Its supposed to look uphill)
Now I know that it would look in the correct direction if the y was the right angle, which is what I need to figure out how to do.
However, if i make a part look in the direction using this code, it works:
workspace.Part.CFrame = CFrame.new(workspace.Part.Position) * CFrameAngles(EnemyData)
The basic part being it.
However, I Cannot do this due to the node changing lots, so I was just wondering if this is an issue I need to realise.