Hello,
I’m making a game like piggy, and I need to use viewport frames, I made one for the bot, however it faces the wrong way!
How can I turn it around?
Here is my script:
local ViewportCamera = Instance.new('Camera',script)
ViewportCamera.CameraType = Enum.CameraType.Scriptable
local RunService = game:GetService('RunService')
local Item = game.ReplicatedStorage:WaitForChild('Instances'):WaitForChild('PlayerImage')
local ViewPortPoint = Vector3.new(0,0,0)
local ViewportFrame = script.Parent:WaitForChild('PlayerViewportFrame')
ViewportFrame.CurrentCamera = ViewportCamera
Item:SetPrimaryPartCFrame(CFrame.new(ViewPortPoint))
Item.Parent = ViewportFrame
RunService.RenderStepped:Connect(function()
local cfrane, size = Item:GetBoundingBox()
local Max = math.max(size.X,size.Y,size.Z)
local Distance = (Max/math.tan(math.rad(ViewportCamera.FieldOfView))) * 2.6
local CurrentDistance = (Max/2) + Distance
ViewportCamera.CFrame = CFrame.new(ViewPortPoint + Vector3.new(0,0,CurrentDistance,ViewPortPoint))
end)
What my NPC looks like in the viewport frame( should be the other way)
Thanks for help!