具体来说,当我按下鼠标左键时,取消停靠动画会重放而不是attack1动画。我已经使用了其他方法但到目前为止没有任何工作,除非有一种方法可以使用动画或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;
}
}
}