大家好,这是我的第一个问答。
我在运行游戏时在控制台选项卡上出现此错误。
Parameter 'speed' does not exist.
UnityEngine.Animator:SetFloat(String,Single) PlayerMovement:FixedUpdate()(在Assets / Scripts / PlayerMovement.cs:30)
有人可以帮我找到问题的根源吗?
谢谢=)
这是我的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
private Animator playerAnimator;
private float moveHorizontal;
private float moveVertical;
private Vector3 movement;
// Use this for initialization
void Start () {
playerAnimator = GetComponent<Animator>();
}
// Update is called once per frame
void Update () {
moveHorizontal = Input.GetAxisRaw ("Horizontal");
moveVertical = Input.GetAxisRaw ("Vertical");
movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
}
void FixedUpdate () {
if (movement != Vector3.zero) {
playerAnimator.SetFloat ("speed", 3f);
} else {
playerAnimator.SetFloat ("speed", 0f);
}
}
}
答案 0 :(得分:0)
Noob错误! &#34;速度&#34;应该大写。我应该有&#34; Speed&#34;,但是已经输入&#34; speed&#34;。
只是让其他人有这个问题......