解决FrogBoss动画切换卡住问题
This commit is contained in:
@@ -33,6 +33,8 @@ public class FrogBleepAttack : Action
|
||||
boss = GetComponent<FrogBoss>();
|
||||
isFinished = false;
|
||||
|
||||
// 标记技能正在执行,防止被中断
|
||||
boss.isSkillExecuting = true;
|
||||
boss.ResetSkill1();
|
||||
boss.StartCoroutine(SkillRoutine());
|
||||
}
|
||||
@@ -64,11 +66,18 @@ public class FrogBleepAttack : Action
|
||||
|
||||
float dis = Vector3.Distance(boss.mouthPoint.position, lockPos);
|
||||
yield return new WaitForSeconds(dis / tongueSpeed);
|
||||
|
||||
// 5️⃣ 吐舌结束立即返回待机(解决延迟问题)
|
||||
boss.Idle();
|
||||
// 5️⃣ 攻击结束 → 后撤(🔥关键)
|
||||
yield return RetreatFromPlayer();
|
||||
|
||||
// 6️⃣ 后撤(并行执行,不阻塞动画切换)
|
||||
boss.StartCoroutine(RetreatFromPlayer());
|
||||
|
||||
// 等待后撤完成
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
|
||||
boss.Idle();
|
||||
boss.isSkillExecuting = false; // 标记技能执行结束
|
||||
isFinished = true;
|
||||
}
|
||||
|
||||
@@ -109,15 +118,18 @@ public class FrogBleepAttack : Action
|
||||
|
||||
Quaternion targetRot = Quaternion.LookRotation(dir);
|
||||
|
||||
while (Quaternion.Angle(transform.rotation, targetRot) > 1f)
|
||||
// 快速转向,减少等待时间
|
||||
while (Quaternion.Angle(transform.rotation, targetRot) > 15f)
|
||||
{
|
||||
transform.rotation = Quaternion.RotateTowards(
|
||||
transform.rotation,
|
||||
targetRot,
|
||||
rotateSpeed * Time.deltaTime
|
||||
720f * Time.deltaTime
|
||||
);
|
||||
yield return null;
|
||||
}
|
||||
// 立即对齐到目标方向
|
||||
transform.rotation = targetRot;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,13 +140,15 @@ public class FrogPoisonAttack : Action
|
||||
{
|
||||
private FrogBoss boss;
|
||||
private bool isFinished;
|
||||
private float rotateSpeed = 360f; // 每秒旋转角度
|
||||
private float rotateSpeed = 360f;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
boss = GetComponent<FrogBoss>();
|
||||
isFinished = false;
|
||||
|
||||
// 标记技能正在执行,防止被中断
|
||||
boss.isSkillExecuting = true;
|
||||
boss.ResetSkill2();
|
||||
boss.StartCoroutine(Attack());
|
||||
}
|
||||
@@ -174,6 +188,7 @@ public class FrogPoisonAttack : Action
|
||||
}
|
||||
|
||||
boss.Idle();
|
||||
boss.isSkillExecuting = false; // 标记技能执行结束
|
||||
isFinished = true;
|
||||
}
|
||||
|
||||
@@ -371,10 +386,11 @@ public class FrogIdleMove : Action
|
||||
return;
|
||||
|
||||
Quaternion targetRot = Quaternion.LookRotation(dir);
|
||||
transform.rotation = Quaternion.RotateTowards(
|
||||
// 使用Slerp实现更平滑的转向
|
||||
transform.rotation = Quaternion.Slerp(
|
||||
transform.rotation,
|
||||
targetRot,
|
||||
rotateSpeed * Time.deltaTime
|
||||
5f * Time.deltaTime
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,13 @@ public class Enemy : MonoBehaviour
|
||||
[HideInInspector] public float skill2Timer;
|
||||
[HideInInspector] public float teleportTimer;
|
||||
|
||||
[HideInInspector] public bool isSkillExecuting;
|
||||
|
||||
public virtual bool HasAnySkillReady()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[Header("Spike")]
|
||||
public int spikeTriggerIndex = 4; // 100%→80→60→40→20
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ public class FrogBoss : Enemy
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
// 如果正在执行技能,不进行自动转向,让技能逻辑自己处理
|
||||
if (isSkillExecuting)
|
||||
return;
|
||||
|
||||
if (enemyState != EnemyState.Show && enemyState != EnemyState.Dead)
|
||||
{
|
||||
skill1Timer += Time.deltaTime;
|
||||
@@ -68,10 +72,11 @@ public class FrogBoss : Enemy
|
||||
|
||||
Quaternion targetRot = Quaternion.LookRotation(dir);
|
||||
|
||||
transform.transform.rotation = Quaternion.RotateTowards(
|
||||
// 使用Slerp实现更平滑的转向,系数约0.1-0.15
|
||||
transform.transform.rotation = Quaternion.Slerp(
|
||||
transform.transform.rotation,
|
||||
targetRot,
|
||||
rotateSpeed * Time.deltaTime
|
||||
5f * Time.deltaTime
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -103,8 +108,12 @@ public class FrogBoss : Enemy
|
||||
|
||||
#region Skill Reset
|
||||
|
||||
public bool HasAnySkillReady()
|
||||
public override bool HasAnySkillReady()
|
||||
{
|
||||
// 如果正在执行技能,不认为技能就绪
|
||||
if (isSkillExecuting)
|
||||
return false;
|
||||
|
||||
return skill1Timer >= skill1Cooldown ||
|
||||
skill2Timer >= skill2Cooldown ||
|
||||
IsUserSkill3();
|
||||
|
||||
Reference in New Issue
Block a user