首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >像素化角色在移动时变形。滞后输入

像素化角色在移动时变形。滞后输入
EN

Stack Overflow用户
提问于 2019-07-10 00:51:00
回答 1查看 33关注 0票数 1

我正在学习一个基本的2d unity游戏的教程。但即使我只有一个角色的动画,当我移动角色时,动画也会变得摇摇欲坠,比如一只眼睛变得比另一只大,或者手臂变大。我链接了一些图片

我不明白为什么会发生这种情况,我该怎么解决呢?此外,我的角色感觉它对我的移动命令反应迟缓,也比它应该停止的晚。我试着让他以恒定的速度移动,然后立即停下来。我不知道哪些是我可以显示的必要代码块,但我尝试将我认为必要的代码块放在下面,下面是我的刚体设置的图片:

代码语言:javascript
复制
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和着色器如下:

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56957288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档