In Japanese translation, the parameter "MoveSpeed" does not exist, but I have confirmed similar errors and common typographical errors in scripts.
A script to reflect the speed of movement in the animator.Thank you for your cooperation.
Error body
Parameter 'MoveSpeed' does not exist.
UnityEngine.Animator: SetFloat (string, single)
PlayerController: Update() (at Assets/iigeemu/script/PlayerController.cs:51)
source code
using System.Collections;
using System.Collections.General;
using UnityEngine;
public class PlayerController: MonoBehavior
{
SerializeField private animator animator;
SerializeField private float moveSpeed=10;
SerializeField private float jumpPower=3;
private CharacterController_characterController;
private Transform_transform;
private Vector3_moveVelocity;
private Transform_transform;
private Vector3_moveVelocity;
// Start is called before the first frame update
void Start()
{
_characterController=GetComponent<CharacterController>();
_transform=transform;
}
// Update is called once per frame
void Update() {
{
Debug.Log(_characterController.isGrounded? "We're on the ground": "We're in the air.");
_moveVelocity.x = Input.GetAxis("Horizontal")*moveSpeed;
_moveVelocity.z = Input.GetAxis("Vertical")*moveSpeed;
_transform.LookAt(_transform.position+newVector3(_moveVelocity.x,0,_moveVelocity.z));
if(_characterController.isGround)
{
if(Input.GetButtonDown("Jump"))
{
Debug.Log("Jump!");
_moveVelocity.y=jumpPower;
}
}
else
{
_moveVelocity.y + = Physics.gravity.y *Time.deltaTime;
}
_characterController.Move(_moveVelocity*Time.deltaTime);
}
animator.SetFloat("MoveSpeed", new Vector3(_moveVelocity.x, 0, _moveVelocity.z).magnitude);
}
}
The Animaor.SetFloat() method passes parameters through the Animator component to the Animator Controller asset (assigned to the Animator component).
The error indicates that the parameter does not exist in the current target Animator Controller.
Also, if you make a mistake in the parameter name, you can correct it, or you can add the parameters of the animator controller and correct them accordingly.
animator.SetFloat ("MoveSpeed" in lowercase to Speed→speed?
© 2024 OneMinuteCode. All rights reserved.