Viewportframe 3d stuff rotation is different, even though it should be the same

So, I am making a loadout system that has guns in it.
My problem is that the CFrame of all guns is the same, and the camera is the same, but they look different even though they have the same CFrame. It looks like the rotation is different, even though it should be the same.

--Snapshot of the ViewportFrame code
local CameraCframe = CFrame.new(-0.662581921, 0.0258705318, 1.44237745, 0.905108869, 0.0243866071, -0.424479514, -0.00285663595, 0.998680353, 0.0512836315, 0.425169855, -0.0452047028, 0.903983951)

function TempletMaker(Gun:BasePart)

	local TempletC = Templet:Clone()
	local GunC = Gun:Clone()
	local ViewPortFrame1 = TempletC:FindFirstChildOfClass("ViewportFrame")
	TempletC.Name = Gun.Name
	TempletC.Parent = ScrollFrame
	ViewPortFrame1.CurrentCamera = Camera
	GunC.Parent =ViewPortFrame1
	GunC.CFrame = gunCFrame
end


here an image

I have already made a viewport system before so I have some ideas about how viewportframe works It looks like the viewportframe camera and model orientation aren’t actually aligned the same even if the cframes match in world space viewportframe uses its own local space so matching the cframe directly doesn’t guarantee the same visual rotation inside the frame you need to align the camera relative to the part orientation inside the viewport not just set the same world CFrame try orienting the gun models relative to the viewport camera position and ensure the camera is positioned and rotated correctly inside the viewport frame not just assigned the same CFrame as a world camera otherwise they will look different because the local transforms are different in the viewport context

local CameraCframe = CFrame.new(
	-0.662581921, 0.0258705318, 1.44237745,
	0.905108869, 0.0243866071, -0.424479514,
	-0.00285663595, 0.998680353, 0.0512836315,
	0.425169855, -0.0452047028, 0.903983951
)

function TempletMaker(Gun: BasePart)
	local TempletC = Templet:Clone()
	local GunC = Gun:Clone()
	local ViewPortFrame1 = TempletC:FindFirstChildOfClass("ViewportFrame")
	TempletC.Name = Gun.Name
	TempletC.Parent = ScrollFrame

	local Camera = Instance.new("Camera", ViewPortFrame1)
	ViewPortFrame1.CurrentCamera = Camera
	Camera.CFrame = CameraCframe
	GunC.CFrame = CameraCframe
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.