Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Unity2D动画或状态机工作不正常_C#_Unity3d - Fatal编程技术网

C# Unity2D动画或状态机工作不正常

C# Unity2D动画或状态机工作不正常,c#,unity3d,C#,Unity3d,我有一个AI机器人,它从我在下面写的一个随机数生成器中获取他的运动输入,然后它相应地动作,但动画状态很混乱。我在下面写了一个动画控制器,但唯一有效的状态是运行和拍摄。如果有人能指出我做错了什么,我会非常感激。谢谢 各州的定义如下: 私有枚举状态{运行、跳跃、下降} 私人国家 我的动画控制器: public void AnimationConditions() { //apparently, these are not working, I don't know why.

我有一个AI机器人,它从我在下面写的一个随机数生成器中获取他的运动输入,然后它相应地动作,但动画状态很混乱。我在下面写了一个动画控制器,但唯一有效的状态是运行和拍摄。如果有人能指出我做错了什么,我会非常感激。谢谢

各州的定义如下:

私有枚举状态{运行、跳跃、下降}

私人国家

我的动画控制器:

public void AnimationConditions()
{   
    //apparently, these are not working, I don't know why. 
    //The sprite is always in a running state or in a shooting state when the shooting trigger is on

    if (rb.velocity.y < 0f)
    {
        state = State.falling;
    }
    else if (rb.velocity.y > 0f) 
    {
        state = State.jumping;
    }
    else state = State.running;
}
void MoveRandomizer(int behaviour, int jumpSpeed)
{
    //0 = change direction to left, 1 = change direction to right, 2 = jump
    //line below is to make the randomised movements occur every "waitTime" seconds

    if((Mathf.Round(timer%waitTime)) == 0)
    {
        if(behaviour == 0)
        {
            movingRight = false;
        }
        else if(behaviour == 1)
        {   
            movingRight = true;
        }
        else if(behaviour == 2)
        {
            rb.velocity = new Vector2(rb.velocity.x, jumpSpeed);
        }
    }
}   
我还在Unity控制台上收到一条错误消息,上面说:

BotController.state已定义但从未使用。(BotController是主脚本的名称)