I position a camera part directly next to a model and it looks super far away, can’t figure out why.
-Local Script No. 1
local WorldModel = script.Parent.Parent.Parent.WeaponSelectView.WorldModel
local Button = script.Parent
local Model = Instance.new("Model")
local FireTool = game.ReplicatedStorage.Tools.Spell_Fire:Clone()
FireTool.Spell.Fire.Anchored = true
FireTool.Spell.Fire.Parent = Model
FireTool.Spell["Sphere.001"].Parent = Model
FireTool:Destroy()
Model.PrimaryPart = Model.Fire
Button.MouseEnter:Connect(function ()
Model.Parent = WorldModel
end)
-Local Script No. 2
local WorldModel = script.Parent
local camera = Instance.new("Camera")
camera.Parent = WorldModel
WorldModel.Parent.ChildAdded:Connect(function (child)
if child:IsA("Model") then
camera.CFrame = CFrame.lookAt(child.PrimaryPart.Position - Vector3.new(1,0,1), child.PrimaryPart.Position)
end
end)
Also, your using lookat which is a CFrame.angles type object. So your coming from 0,0,0 (Center of Game) and then rotating it from 0,0,0 (Center of Game) to the part that was just added. So you have to put the Camera closer to the object.
Depending on the size of your part and the size of the viewport window, the part may look small even with a camera that is only 1 stud away.
The size of the part isn’t scaling with the viewport window, rather the viewport window size is expanding the scope of what is shown without changing the zoom of the camera.
You may need to experiment with the distance you are moving the camera; try 0.5, then 0.4, etc. until you get the right size you want for the size of your window. Additionally, you may need to do this for each object shown; if their sizes are a constant, it shouldn’t be a problem (however, any variability will result in a variability in the viewport window). This also applies to the front face of the object; if the front face is a constant for every weapon, this won’t matter, but otherwise, you may need to change the viewport camera CFrame for each.
In my game, I’ve had to alter the CFrame per object often. If the size and front face matches another object, I can skip this and copy those settings. Otherwise, I go into a play test session and alter the CFrame on runtime until it looks desirable (then I copy and save those settings in a module script dedicated to recording settings data).
Edit; this information isn’t fresh (I haven’t recently reviewed my code or viewport behavior), feel free to correct me. I am not 100% sure that the viewport size doesn’t scale the resulting image. In any case, an iterative approach helped me a lot in setting up my viewport cameras.
I would do that, but my problem is even when adjusting the distance the view still looks exactly the same. Here is an image when the distance is at 0.1
There is CurrentCamera property in viewport have you tried set the newly created camera to viewport yet?
Example (If your viewport is directly above WorldMode)
local WorldModel = script.Parent
local Viewport = WorldModel.Parent :: ViewportFrame
local camera = Instance.new("Camera")
camera.Parent = WorldModel.Parent
Viewport.CurrentCamera = camera