具体来说,当我按下鼠标左键时,会重播取消停靠动画而不是 attack1 动画。我使用了替代方法,但到目前为止没有任何效果,除非有一种方法可以使用我尚未尝试过的其他方法,使用 Animation 或 AnimationClip。我对 Unity 很陌生,所以任何帮助都会很棒。另外,如果有人知道为什么空闲动画的条件也没有激活,那将非常有帮助,感谢任何可以提供帮助的人。
{
[Range(10, 200)]
public float triggerDistance;
private bool attacking;
public Animator attack1;
//public MovementScript movementScript;
public Animator tenticleAnimationDocking;
public Animator tenticleAnimationUndocking;
public Animator idle;
public Transform centre;
public Transform missileOrigin;
private bool dockingAnimationPlaying;
private bool undockingAnimationPlaying;
private bool attackAnimationPlaying;
void Start()
{
tenticleAnimationDocking = GetComponent<Animator>();
tenticleAnimationUndocking = GetComponent<Animator>();
idle = GetComponent<Animator>();
attack1 = GetComponent<Animator>();
GetComponent<Rigidbody>();
//movementScript = GetComponent<MovementScript>();
}
private void Update()
{
if (attacking)
Attacking();
if (Vector3.Distance(centre.position, missileOrigin.position) < triggerDistance) {
tenticleAnimationUndocking.Play("Undocking");
undockingAnimationPlaying = true;
}else{
undockingAnimationPlaying = false;
}
if (Input.GetMouseButtonDown(0)) {
Attacking();
attackAnimationPlaying = true;
}else{
attackAnimationPlaying = false;
}
if (Vector3.Distance(centre.position, missileOrigin.position) < triggerDistance)
if (dockingAnimationPlaying == false)
if (undockingAnimationPlaying == false)
if (attackAnimationPlaying == false)
{
idle.Play("Idle");
}
if (EnemySpawn.totalMissileCount >= 40) {
Reattach();
dockingAnimationPlaying = true;
}else{
dockingAnimationPlaying = false;
}
}
private void Reattach()
{
tenticleAnimationDocking.Play("Docking");
}
private void Attacking()
{
CheckAnimation();
attack1.Play("Attacking");
}
private void CheckAnimation()
{
if (attacking)
{
attacking = false;
}
else
{
attacking = true;
}
}
}