我正在学习一个基本的2d unity游戏的教程。但即使我只有一个角色的动画,当我移动角色时,动画也会变得摇摇欲坠,比如一只眼睛变得比另一只大,或者手臂变大。我链接了一些图片
我不明白为什么会发生这种情况,我该怎么解决呢?此外,我的角色感觉它对我的移动命令反应迟缓,也比它应该停止的晚。我试着让他以恒定的速度移动,然后立即停下来。我不知道哪些是我可以显示的必要代码块,但我尝试将我认为必要的代码块放在下面,下面是我的刚体设置的图片:
。
public class PlayerController : MonoBehaviour
{
public Vector2 movementDirection;
public float movementSpeed;
public Rigidbody2D rb;
public float BASE_MOVE_SPEED = 1.0f;
public Animator animator;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
processInputs();
move();
animate();
}
void processInputs() {
movementDirection = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
movementSpeed = Mathf.Clamp(movementDirection.magnitude, 0.0f, 1.0f);
movementDirection.Normalize();
}
void move()
{
rb.velocity = movementDirection *BASE_MOVE_SPEED* movementSpeed * Time.deltaTime;
}
void animate()
{
animator.SetFloat("Horizontal", movementDirection.x);
animator.SetFloat("Vertical", movementDirection.y);
}
}
我的SpriteRenderer和着色器如下:
https://stackoverflow.com/questions/56957288
复制相似问题