So basically I have been scripting for about 2-4 months now and its only now that I am starting to get the hang of things. So today I decided to sharpen up on my camera manipulation by making a ViewportFrame GUI with a spinning part in it. I used this developer hub article to make the camera rotate:
The problem is that the script was quite hardish to understand but eventually I think I understood it, but now there is a certain part that no matter what I just can’t get around if anyone can explain in detail what this does it would really help. :
In this script you are constantly firing a function, updateCamera(), until a tween has completed. Among other stuff, this function creates a CFrame called “rotatedCFrame” from an angle - that’s why you call CFrame.Angles() (in which the angles must be expressed in radians). Then (line 19) you set the current camera’s CFrame offseting a Vector3 from the rotatedCFrame.
As you know, CFrame is a property that holds information for both the position and orientation of an object, either a basepart or the camera. Well, these commands (lines 18 and 19) are essentially changing the camera’s orientation and adjusting its position (in a smooth way thanks to TweenService). In fact, this is the point of the whole script. The rotation is overwritten when lookAtTarget is true though (line 20).
You might have already read this tutorial on CFrame, but I’m leaving it here just in case. Also here you can find more information on setting the camera’s CFrame. By the way, the best you can do to understand CFrame and camera is to experiment with them!
Thanks so much for the explanation, I really appreciate it. Also, I will try go through that article about CFrames again and just keep experimenting with them.