2025-01-04 23:00:19 +08:00

73 lines
2.8 KiB
Lua

---@class BP_RotatorShootingTarget_C:Character
---@field Cube UStaticMeshComponent
---@field SpawnSphereRadius USphereComponent
---@field Center USceneComponent
---@field SpawnNum int32
---@field ShootingTargetClass UClass
---@field EnableRotator bool
---@field YawSpeed float
--Edit Below--
local BP_RotatorShootingTarget = {};
function BP_RotatorShootingTarget:ReceiveBeginPlay()
self.SuperClass.ReceiveBeginPlay(self);
if UGCGameSystem.IsServer() then
self:SpawnShootingTargets()
self:SpawnDefaultController()
end
end
function BP_RotatorShootingTarget:SpawnShootingTargets()
local ForwardVector = self:GetActorForwardVector()
local SphereRadius = self.SpawnSphereRadius:GetScaledSphereRadius()
local SelfPos = self:K2_GetActorLocation()
local HalfHeight = self.CapsuleComponent:GetScaledCapsuleHalfHeight()
SelfPos.Z = SelfPos.Z - HalfHeight
UGCLogSystem.Log("[BP_RotatorShootingTarget_SpawnShootingTargets] HalfHeight:%s", tostring(HalfHeight))
for i = 0, self.SpawnNum - 1 do
local TempForward = KismetMathLibrary.GreaterGreater_VectorRotator(ForwardVector, {Roll = 0., Pitch = 0., Yaw = 360./ self.SpawnNum * i})
local TargetPos = VectorHelper.Add(SelfPos, VectorHelper.MulNumber(TempForward, SphereRadius))
local TargetRot = KismetMathLibrary.MakeRotFromX(KismetMathLibrary.GreaterGreater_VectorRotator(TempForward, {Roll = 0., Pitch = 0., Yaw = 180}))
local ChildShootingTarget = UGCGameSystem.SpawnActor(self, self.ShootingTargetClass,TargetPos, TargetRot, VectorHelper.ScaleOne(), self)
---@field K2_AttachToComponent fun(Parent:USceneComponent,SocketName:FName,LocationRule:EAttachmentRule,RotationRule:EAttachmentRule,ScaleRule:EAttachmentRule,bWeldSimulatedBodies:bool)
ChildShootingTarget:K2_AttachToComponent(self.Center, "", EAttachmentRule.KeepWorld, EAttachmentRule.KeepWorld, EAttachmentRule.KeepWorld)
end
end
function BP_RotatorShootingTarget:ReceiveTick(DeltaTime)
self.SuperClass.ReceiveTick(self, DeltaTime);
if self.EnableRotator then
-- self:AddControllerYawInput(self.YawSpeed)
self:K2_AddActorLocalRotation({Roll = 0., Pitch = 0., Yaw = self.YawSpeed * DeltaTime})
end
if UGCGameSystem.IsServer() then
-- self:FaceRotation({Roll = 0., Pitch = 0., Yaw = self.YawSpeed}, DeltaTime)
--if self.EnableRotator then
-- -- self:AddControllerYawInput(self.YawSpeed)
-- self:K2_AddActorLocalRotation({Roll = 0., Pitch = 0., Yaw = self.YawSpeed * DeltaTime})
--end
end
end
--[[
function BP_RotatorShootingTarget:ReceiveEndPlay()
self.SuperClass.ReceiveEndPlay(self);
end
--]]
--[[
function BP_RotatorShootingTarget:GetReplicatedProperties()
return
end
--]]
--[[
function BP_RotatorShootingTarget:GetAvailableServerRPCs()
return
end
--]]
return BP_RotatorShootingTarget;