bagon03
(Bag)
December 6, 2023, 6:40am
#1
Hello, I am a novice to camera manipulation and I have this issue where the camera will snap to the Z Axis upon spawning in or using this line of code below. Is there an alternative to make it smoothly transition towards this camera. I know -50000 is the reason but any time I change it, it breaks the camera.
https://gyazo.com/513becdedad81c0bf76f1167798746da
local startCFrame = CFrame.new((rootPart.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, math.rad(xAngle), 0)*CFrame.Angles(math.rad(yAngle), 0, 0)
--Set camera focus and cframe
local cameraCFrame = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(cameraPos.X,cameraPos.Y,cameraPos.Z))
local cameraFocus = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(cameraPos.X,cameraPos.Y,-50000))
Camera.CFrame = CFrame.new(cameraCFrame.p,cameraFocus.p)
2 Likes
SnarlyZoo
(SnarlyZoo)
December 6, 2023, 4:12pm
#2
What are you trying to do with the camera? I am confused on what you are trying to accomplish with this code.
If you want a simple 3rd person camera script, multiply your startCFrame variable by a new CFrame for your 3rd person offset:
local startCFrame = CFrame.new((rootPart.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, math.rad(xAngle), 0)*CFrame.Angles(math.rad(yAngle), 0, 0)
Camera.CFrame = startCFrame * CFrame.new(0, 0, 10)
With the above code the camera will be 10 studs behind the character.
bagon03
(Bag)
December 6, 2023, 8:29pm
#3
It’s just a regular camera; however, if you look at the gyazo every time I press a button the camera snaps and my whole screen rotates.
I don’t know if you have already set the camera to scriptable, but if not, it is better to change to the humanoid’s CameraOffSet
1 Like