首页 > 解决方案 > Unity3d 游戏教程 Scavengers 2D 我的角色只移动一次

问题描述

我是创建游戏的新手,我正在用 C# 编程,我需要帮助,因为我花了很多时间尝试将 Unity3d 教程游戏制作为 2D Scavengers,而我的角色只移动一次其余的都是正常的。Unity 不收取这方面的任何错误。有人可以帮助我吗?

我多次尝试将我的代码与视频课程的代码进行比较,但没有发现任何区别。

private void Update()
{
    //Só vamos fazer alguma coisa se for o turno do player
    if(!GameManager.instance.playerTurn)return;

    int horizontal = 0;
    int vertical = 0;

    horizontal = (int) (Input.GetAxisRaw("Horizontal"));

    vertical = (int) (Input.GetAxisRaw("Vertical"));

    if(horizontal != 0)
    {   
        vertical = 0;
    }

    if(horizontal != 0 || vertical != 0)
    {
        AttemptMove<Wall> (horizontal, vertical);
    }
}

标签: c#unity3d

解决方案


推荐阅读