I don't know what I'm missing in interpolation

So my code is:

script.Parent.MouseButton1Click:Connect(function()
	workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
	workspace.CurrentCamera:Interpolate(CFrame.new(script.Parent.Parent.Parent.Adornee.Position.X, script.Parent.Parent.Parent.Adornee.Position.Y, script.Parent.Parent.Parent.Adornee.Position.Z - 5) * CFrame.Angles(script.Parent.Parent.Parent.Adornee.Orientation), CFrame.new(script.Parent.Parent.Parent.Adornee.Position), 1)
end)

I get this error when I run it though:

I really don’t know why this is happening, I quite clearly have all 3 arguments, but the error tells me there isn’t any value when in this case, it’s 1. Please help!

and before you say, dont be complaining about the parents :expressionless:

Are you saying the second argument needs to be an angle? If so, how can I automatically find the angle of the part for the camera to look at it? I’m assuming I’d just find the opposite if the number says 180 would become -180 (or 0)

I believe your issue isn’t the interpolate function, but rather CFrame.Angles(script.Parent.Parent.Parent.Adornee.Orientation)

CFrame.Angles doesn’t have a constructor that accepts a Vector3. You can use CFrame.fromOrientation, however you’ll have to pass in the X, Y and Z angles as seperate arguments.

4 Likes

Oh that worked, thank you! I assumed Orientation was Vector3, obviously not.

I was mistaken, I was thinking of lerp, not interpolation on cameras.

In this case, I believe the above poster (@fireboltofdeath) was correct.

Might also be worth noting that CFrame.Angles == CFrame.fromOrientation == CFrame.fromEulerAnglesXYZ. Either function would work: I prefer Angles personally because of the naming convention. Just gotta be mindful that these functions work in radians.

I believe that you could break the CFrame down into its rotational components so that you avoid using the Orientation Vector3 and that should work well enough for forming back a rotated CFrame.

local RX, RY, RZ = SomeCFrame:ToOrientation()
local RotatedCFrame = CFrame.Angles(RX, RY, RZ)

-- Later
Camera:Interpolate(PositionCFrame * RotatedCFrame, SecondCFrame, Alpha)
2 Likes

Yes, although I’m pretty sure OP’s “Adornee” property is just a BasePart, so he could probably just use the CFrame + 5 depth, which I didn’t notice before.

Also, I’m not 100% sure if this is correct however according to developer wiki, CFrame.fromOrientation and ToOrientation is based on YXZ, while CFrame.Angles is based on XYZ.

2 Likes

Ooops. Yeah, didn’t catch that. The application of rotations is different.

image

fromOrientation would make more sense to go with ToOrientation. I’m generally accustomed to using Angles otherwise when I have rotated CFrames.

I hope I don’t have to go back and change anything…

1 Like