【问题标题】:unity 2D player movement parameters do not existunity 2D 玩家运动参数不存在
【发布时间】:2015-01-19 03:19:26
【问题描述】:

现在我正在浏览动画,我已经成功地制作了一个自上而下的小型射击游戏。我遵循了pixelnest.io的几个教程,但奇怪的是我收到一条错误消息,说“参数'moveRight'不存在。统一的动画对我来说是全新的,并且一直在尝试尽可能多地阅读。任何修复动画以便在我向右移动时播放的建议?下面是一些图片和我的代码。

using UnityEngine;

使用 System.Collections;

公共类 playerMove : MonoBehaviour {

public float maxSpeed = 5f;
Animator animator;
bool isRight;

void Awake(){
    animator = GetComponent<Animator>();
}

void Update(){
    Vector3 posMove = transform.position;
    Vector3 velocityH = new Vector3 (Input.GetAxis ("Horizontal") * maxSpeed * Time.deltaTime, 0, 0);
    //this is just test a before i add it to the right movement
    animator.SetBool ("moveRight", isRight);


    Vector3 velocityV = new Vector3 (0, Input.GetAxis ("Vertical") * maxSpeed * Time.deltaTime, 0);
    posMove += velocityH + velocityV;
    transform.position = posMove;
}

}

【问题讨论】:

    标签: c# unity3d


    【解决方案1】:

    这是因为您的动画师中没有名为“moveRight”的布尔值。
    查看您发布的第一个屏幕截图。在左下角,您声明了一个名为“isRight”的布尔值。

    使用Animator.SetBool(yourBool, boolValue) 时,您需要传递的第一个参数是动画器中声明的布尔值的名称(在本例中为“isRight”)。

    更改脚本中的以下代码行

    改变这一行

    animator.SetBool ("moveRight", isRight);
    

    阅读

    animator.SetBool ("isRight", isRight);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 2017-02-20
      • 2021-11-03
      • 1970-01-01
      • 1970-01-01
      • 2022-10-15
      相关资源
      最近更新 更多