增加敌人攻击特效和音效

This commit is contained in:
2026-07-05 13:44:49 +08:00
parent aa9482875c
commit 4da7bdb9a4
5 changed files with 43 additions and 7 deletions
+13 -3
View File
@@ -238,11 +238,21 @@ namespace IndianOceanAssets.Engine2_5D
_animator.SetTrigger(attackAnimTrigger);
}
// 播放攻击粒子特效(生成在玩家位置,模拟命中效果)
// 播放攻击粒子特效 + 音效(生成在玩家位置,模拟命中效果)
if (attackParticlePrefab != null)
{
Vector3 spawnPos = playerTarget != null ? playerTarget.position : transform.position;
GameObject fx = Instantiate(attackParticlePrefab, spawnPos, transform.rotation);
Vector3 spawnPos = transform.position;
// Z轴180°翻转修正特效方向
Quaternion fxRotation = transform.rotation * Quaternion.Euler(0, 0, 180);
GameObject fx = Instantiate(attackParticlePrefab, spawnPos, fxRotation);
// 预制体的 playOnAwake 关闭,需要手动播放粒子特效和音效
var ps = fx.GetComponent<ParticleSystem>();
if (ps != null) ps.Play();
var audio = fx.GetComponent<AudioSource>();
if (audio != null) audio.Play();
Destroy(fx, 2f);
}
}