---@class BP_LaunchCube_C:AActor ---@field Box UBoxComponent ---@field JumpArrow UStaticMeshComponent ---@field StaticMesh UStaticMeshComponent ---@field DefaultSceneRoot USceneComponent ---@field EnableLaunch bool ---@field LaunchZSpeed float ---@field EnableDisappear bool ---@field DelayDisappearTime float ---@field DisappearResetTime float ---@field Sound UAkAudioEvent --Edit Below-- local BP_BaseMultiCube = { IsHiding = false }; function BP_BaseMultiCube:ReceiveBeginPlay() self.SuperClass.ReceiveBeginPlay(self); if UGCGameSystem.IsServer() then UGCSystemLibrary.BindBeginOverlapFunc(self.Box, self.OverlapPlayer, self) end end function BP_BaseMultiCube:OverlapPlayer(OverlappedComp, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult) if self.IsHiding then return end -- Launch if self.EnableLaunch and UE.IsValid(OtherActor) and OtherActor:IsAlive() then local PlayerCharacter = OtherActor local JumpDir = self.JumpArrow:GetForwardVector() local VelocityDot = KismetMathLibrary.Dot_VectorVector(JumpDir, PlayerCharacter.CharacterMovement.Velocity) --考虑角色跳起来的情况 if VelocityDot < 0 then local AddSpeed = self.LaunchZSpeed - VelocityDot OtherActor.CharacterMovement:AddImpulse(VectorHelper.MulNumber(JumpDir, AddSpeed), true) elseif PlayerCharacter.CharacterMovement.Velocity.Z == 0 then OtherActor.CharacterMovement:AddImpulse(VectorHelper.MulNumber(JumpDir, self.LaunchZSpeed), true) end end -- Disappear if self.EnableDisappear then UGCEventSystem.SetTimer(self, function() self.StaticMesh:SetCollisionEnabled(ECollisionEnabled.NoCollision) end, self.DelayDisappearTime) UGCEventSystem.SetTimer(self, self.ResetCube, self.DelayDisappearTime + self.DisappearResetTime) self.IsHiding = true end UGCSendRPCSystem.ActorRPCNotify(nil, self, "ClientEffect") end function BP_BaseMultiCube:ResetCube() -- 开启碰撞 self.StaticMesh:SetCollisionEnabled(ECollisionEnabled.QueryAndPhysics) if UGCGameSystem.IsServer() then -- 服务器发送RPC UGCSendRPCSystem.ActorRPCNotify(nil, self, "ResetCube") self.IsHiding = false else -- 显示网格 self.StaticMesh:SetHiddenInGame(false, true) end end function BP_BaseMultiCube:ClientEffect() if self.EnableDisappear then -- 延迟一小段时间关闭碰撞 UGCEventSystem.SetTimer(self, function() self.StaticMesh:SetCollisionEnabled(ECollisionEnabled.NoCollision) end, self.DelayDisappearTime) -- 隐藏网格 self.StaticMesh:SetHiddenInGame(true, true) end -- 播放音效 UGCSoundManagerSystem.PlaySoundAtLocation(self.Sound, self:K2_GetActorLocation(), VectorHelper.RotZero()) -- 播放粒子 end --[[ function BP_BaseMultiCube:ReceiveTick(DeltaTime) self.SuperClass.ReceiveTick(self, DeltaTime); end --]] --[[ function BP_BaseMultiCube:ReceiveEndPlay() self.SuperClass.ReceiveEndPlay(self); end --]] --[[ function BP_BaseMultiCube:GetReplicatedProperties() return end --]] --[[ function BP_BaseMultiCube:GetAvailableServerRPCs() return end --]] return BP_BaseMultiCube;