2015-04-12 57 views
0

我想让我的角色在按“P”时射击。我创建了一个名为shoot的触发器,并且在动画器状态机中,已经将拍摄动画来回连接到空闲动画。无论我尝试过什么,按下“p”时,“拍摄”动画都会拒绝播放。我的“run”参数包含从idle-> run的动画混合树,在按D或A时完美地工作,然而,每当我按下P时,不想拍摄,只停留在空闲状态。任何想法我做错了什么?'射击'动画不能在Unity中播放

预先感谢您

编辑: 动画图像

http://i60.tinypic.com/i6kq9t.png

using UnityEngine; 
using System.Collections; 

public class NewSoldier : MonoBehaviour { 

Animator animator; 
bool Shoot; 
float Running = 0.08f; 

// Use this for initialization 
void Start() { 
    //float Run; 
    animator = GetComponent<Animator>(); 
} 

// Update is called once per frame 
void Update() { 

    float speed = Input.GetAxis ("Horizontal"); 

    if (Input.GetKey ("d")) { 

        this.transform.Translate (Input.GetAxis ("Vertical"), 0, Running); 
        transform.rotation = Quaternion.Euler (0, 90, 0); 
        animator.SetFloat ("Run", Mathf.Abs (speed)); 
      } 
    else if (Input.GetKey ("a")) 
      { 

        this.transform.Translate (Input.GetAxis ("Vertical"), 0, Running); 
        transform.rotation = Quaternion.Euler (0, -90, 0); 
        animator.SetFloat ("Run", Mathf.Abs (-(speed))); 
      } 
    else if (Input.GetKeyDown ("p")) 
      { 

        animator.SetBool("Shoot", true); 
        animator.SetTrigger ("Shoot"); 
      } 

    else   
      { 
       bool Shoot = false; 
       animator.SetFloat ("Run", Mathf.Abs(speed)); 
      } 
    } 
} 

回答

0

你在你的动画树设置什么事件去拍摄动画? 它可能是一些东西:

  • 您的动画更改未设置为事件;
  • 您的动画更改设置为浮动,并且您正在使用布尔和触发器;
  • 如果您的动画更改是触发器,则只需用户SetTrigger;
  • 您的动画更改可能未设置为从运行到拍摄;
  • 也许你的事件变化不是“拍摄”,因为你误按了一个键,而你没有注意到;

如果你能向我们展示一棵树的图案,会很好。此外,我你按一个或d,它不会拍

+0

喜穗, 我附上了动画的截图: http://i60.tinypic.com/i6kq9t.png (低代表所以不能使用stackoverflows功能)。 我无法发现问题。此刻我希望自己的角色能够在他只是空闲时按'p'的时候进行拍摄。一旦我可以完美的,那么我可以添加运行等转换。 –

+0

任何一个有想法:( –