Hello, I have a viewportframecamera and I had a camera. I set the viewportframe’s “currentCamera” to the camera then I am inserting parts into the viewportframe to display in my shop. I am trying to make a script that automatically adjusts the position of the part and its rotation in the viewportframe camera so that they are all correctly in picture. What is a script I can use to automatically adjust the parts rotation and position to fit in the picture regardless of the objects size?
I don’t have a script to provide except for
local viewportframe = script.Parent
local camera = script.Parent.Parent.Camera
local part = script.Parent.Parent.Part
local rand = math.random(1,10)
part.Parent = viewportframe
part.Size = Vector3.new(rand,rand,rand)
--// sets size to random to represent that I want it to be same regarldess of size
--add code here to adjust the position and rotation to be the same regardless of size
the focus arguement of camera requires a position and orientation however I am asking for it to be automatically done with a script so I don’t manually enter positions
I remember doing this long ago with a script but I forgot how
If you’re reffering to the “camerasubject” property of camera then know I tested and it doesnt worrk
You cannot add a vector3 to a CFrame. You also cannot set the position to a CFrame.
to set an objects CFrame you do
object.CFrame = (cframe)
in the case, you are only able to set the cameras focus to a CFrame and not vector3. A CFrame is the combination of both a vector3 position and a orientation into one thing.