ParticleConfig = ParticleConfig or {} ParticleConfig.EParticleType = { AddBuff = 1; GodOfWar = 2; GodOfWarSelf = 3; Ice = 4; } ParticleConfig.ParticleInfoList = { [ParticleConfig.EParticleType.AddBuff] = { Path = UGCGameSystem.GetUGCResourcesFullPath('Asset/FX/BuffFx/P_AddBuff2.P_AddBuff2'); Position = { X = 0, Y = 0, Z = -85 }; AttachName = ""; }; [ParticleConfig.EParticleType.GodOfWar] = { Path = UGCGameSystem.GetUGCResourcesFullPath('Asset/FX/GodOfWar/P_GodOfWar.P_GodOfWar'); Position = { X = 0, Y = 0, Z = -85 }; AttachName = ""; Rot = {Roll = 0., Pitch = 0., Yaw = -90}; Scale = 2; IsFaseToLocalPlayer = true; IsZeroYaw = true; }; [ParticleConfig.EParticleType.GodOfWarSelf] = { Path = UGCGameSystem.GetUGCResourcesFullPath('Asset/FX/GodOfWar/P_GodOfWar_Self.P_GodOfWar_Self'); Position = { X = 0, Y = 0, Z = -85 }; AttachName = ""; Scale = 2; IsZeroYaw = true; }; [ParticleConfig.EParticleType.Ice] = { Path = UGCGameSystem.GetUGCResourcesFullPath('Asset/FX/GodOfWar/P_Ice.P_Ice'); Position = { X = 0, Y = 0, Z = 110 }; AttachName = ""; Scale = 1.5; IsZeroYaw = true; AttachLocation = EAttachLocation.SnapToTarget; }; } ParticleConfig.ParticleInst = {} function ParticleConfig.PreLoad() for ParticleType, ParticleInfo in pairs(ParticleConfig.ParticleInfoList) do ParticleConfig.ParticleInst[ParticleType] = UGCSystemLibrary.LoadAsset(ParticleInfo.Path) end end function ParticleConfig.GetParticleInst(InParticleType) if ParticleConfig.ParticleInst[InParticleType] == nil then ParticleConfig.ParticleInst[InParticleType] = UGCSystemLibrary.LoadAsset(ParticleConfig.ParticleInfoList[InParticleType].Path) end return ParticleConfig.ParticleInst[InParticleType] end --- 在玩家网格中心生成粒子 function ParticleConfig.AddParticleAttachPlayer(InPawn, ParticleType) if UE.IsValid(InPawn) then local Position = VectorHelper.VectorZero() local ComposeRotators = VectorHelper.RotZero() local Rot = InPawn:K2_GetActorRotation() local Scale = 1 local AttachLocation = EAttachLocation.SnapToTarget if ParticleConfig.ParticleInfoList[ParticleType].Position then Position = ParticleConfig.ParticleInfoList[ParticleType].Position end if ParticleConfig.ParticleInfoList[ParticleType].Scale then Scale = ParticleConfig.ParticleInfoList[ParticleType].Scale end if ParticleConfig.ParticleInfoList[ParticleType].Rot then ComposeRotators = ParticleConfig.ParticleInfoList[ParticleType].Rot end if ParticleConfig.ParticleInfoList[ParticleType].AttachLocation then AttachLocation = ParticleConfig.ParticleInfoList[ParticleType].AttachLocation end if ParticleConfig.ParticleInfoList[ParticleType].IsFaseToLocalPlayer then local CameraManager = UGCSystemLibrary.GetLocalPlayerController().PlayerCameraManager local CameraPos = CameraManager:K2_GetActorLocation() Rot = KismetMathLibrary.MakeRotFromX(VectorHelper.Sub(CameraPos, InPawn:K2_GetActorLocation())) if ParticleConfig.ParticleInfoList[ParticleType].IsZeroYaw then Rot.Yaw = 0; end end return GameplayStatics.SpawnEmitterAttached( ParticleConfig.GetParticleInst(ParticleType), InPawn.Mesh, ParticleConfig.ParticleInfoList[ParticleType].AttachName, Position, KismetMathLibrary.ComposeRotators(InPawn:K2_GetActorRotation(), ComposeRotators), { X = Scale, Y = Scale, Z = Scale }, AttachLocation, false ) end return nil end function ParticleConfig.DestroyParticle(InParticleInst) if UE.IsValid(InParticleInst) then InParticleInst:K2_DestroyComponent() end end