---@class BP_TrackKillerCamera_C:AActor ---@field Camera UCameraComponent ---@field CustomSpringArm UCustomSpringArmComponent ---@field DefaultSceneRoot USceneComponent ---@field EnableTime float ---@field InterpSpeed float --Edit Below-- ---@type BP_TrackKillerCamera_C local BP_TrackKillerCamera = { bEnableMove = false; KillerPawn = nil; DelayDisableHandle = nil; }; function BP_TrackKillerCamera:ReceiveBeginPlay() --if self.IsExeBeginPlay then return end --self.IsExeBeginPlay = true self.SuperClass.ReceiveBeginPlay(self); UGCLogSystem.Log("[BP_TrackKillerCamera_ReceiveBeginPlay] 1") if not UGCGameSystem.IsServer() then UGCEventSystem.AddListener(EventEnum.PlayerDeathInfo, self.PlayerDeath, self) UGCLogSystem.Log("[BP_TrackKillerCamera_ReceiveBeginPlay] 2") end end function BP_TrackKillerCamera:PlayerDeath(VictimKey, CauserKey) if GlobalConfigs.GameSetting.EnableLerpCamera then UGCLogSystem.Log("[BP_TrackKillerCamera_PlayerDeath]") if UGCSystemLibrary.GetLocalPlayerKey() == VictimKey then UGCLogSystem.Log("[BP_TrackKillerCamera_PlayerDeath] VictimKey:%d, CauserKey:%d ", VictimKey, CauserKey) self.KillerPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(CauserKey) if UE.IsValid(self.KillerPawn) then local TargetPos_ = self.KillerPawn:K2_GetActorLocation() local TargetRot_ = self.KillerPawn:K2_GetActorRotation() self:K2_SetActorLocation(TargetPos_) self:K2_SetActorRotation(TargetRot_) self.bEnableMove = true if self.DelayDisableHandle ~= nil then UGCEventSystem.StopTimer(self.DelayDisableHandle) self.DelayDisableHandle = nil end self.DelayDisableHandle = UGCEventSystem.SetTimer(self, function() self.bEnableMove = false end, self.EnableTime) else UGCLogSystem.LogError("[BP_TrackKillerCamera_PlayerDeath] KillerPawn is nil. CauserKey:%s", tostring(CauserKey)) end end end end function BP_TrackKillerCamera:GetTargetPosAndRot() return self.KillerPawn:K2_GetActorLocation(), self.KillerPawn:K2_GetActorRotation() -- return self.KillerPawn.ScopingCamera:K2_GetComponentLocation(), self.KillerPawn.ScopingCamera:K2_GetComponentRotation() end function BP_TrackKillerCamera:ReceiveTick(DeltaTime) self.SuperClass.ReceiveTick(self, DeltaTime); -- self:ReceiveBeginPlay() if self.bEnableMove then if UE.IsValid(self.KillerPawn) then local TargetPos_, TargetRot_ = self:GetTargetPosAndRot() local Pos = KismetMathLibrary.VInterpTo(self:K2_GetActorLocation(), TargetPos_, DeltaTime, self.InterpSpeed) local Rot = KismetMathLibrary.RInterpTo(self:K2_GetActorRotation(), TargetRot_, DeltaTime, self.InterpSpeed) self:K2_SetActorLocation(Pos) self:K2_SetActorRotation(Rot) else UGCLogSystem.Log("[BP_TrackKillerCamera_ReceiveTick] KillerPawn is nil") self.bEnableMove = false end end end return BP_TrackKillerCamera;