41 lines
1.4 KiB
Lua
41 lines
1.4 KiB
Lua
|
local CameraManager = LuaClass("CameraManager")
|
||
|
|
||
|
CameraManager.OwnerController = nil
|
||
|
CameraManager.OverlookCamera = nil
|
||
|
|
||
|
function CameraManager:ctor(OwnerController)
|
||
|
UE.Log("[CameraManager:ctor]")
|
||
|
|
||
|
if OwnerController == nil then
|
||
|
local Controller = GameDataManager.OwnerPlayerController
|
||
|
self.OwnerController = Controller
|
||
|
return
|
||
|
end
|
||
|
|
||
|
self.OwnerController = OwnerController
|
||
|
end
|
||
|
|
||
|
function CameraManager:SetupOverlookCamera()
|
||
|
if self.OwnerController == nil or UE.IsValid(self.OwnerController) == false then
|
||
|
UE.LogError("[CameraManager:SetupOverlookCamera] invalid OwnerController")
|
||
|
return
|
||
|
end
|
||
|
|
||
|
local WorldContextObject = self.OwnerController
|
||
|
AsyncLoadTools:LoadObject(BPClassPath.CustomCameraActor,
|
||
|
function(CameraClass)
|
||
|
local Pawn = WorldContextObject:K2_GetPawn()
|
||
|
if Pawn then
|
||
|
local Camera = UGCGameSystem.SpawnActor(WorldContextObject, CameraClass, Pawn:K2_GetActorLocation(), VectorHelper.RotZero(), VectorHelper.ScaleOne(), WorldContextObject)
|
||
|
Camera:K2_AttachToComponent(Pawn.CameraSocket, "", EAttachmentRule.SnapToTarget, EAttachmentRule.SnapToTarget, EAttachmentRule.SnapToTarget, false)
|
||
|
self.OverlookCamera = Camera
|
||
|
WorldContextObject:SetViewTargetWithBlend(Camera, 0, EViewTargetBlendFunction.VTBlend_Linear, 0, false)
|
||
|
end
|
||
|
end)
|
||
|
end
|
||
|
|
||
|
function CameraManager:GetCamera()
|
||
|
return self.OverlookCamera
|
||
|
end
|
||
|
|
||
|
return CameraManager
|