C# 统一2D,我无法解决它

C# 统一2D,我无法解决它,c#,unity3d,C#,Unity3d,我试图制作一个platformer游戏,但当我创建秋季动画时,它显示了以下错误CS1026:if(Player,whatIsGround==0){ 代码如下: using System.Collections; using System.Collections.Generic; using UnityEngine; public class CharacterAnim : MonoBehaviour { private Animator anim; public LayerMask wha

我试图制作一个platformer游戏,但当我创建秋季动画时,它显示了以下错误CS1026:
if(Player,whatIsGround==0){

代码如下:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharacterAnim : MonoBehaviour {

private Animator anim;

public LayerMask whatIsGround;

public float Player;


void Start(){
    anim = GetComponent<Animator>();
}

void Update(){

    if(Player, whatIsGround == 0){

        anim.SetBool("Test", true);
    } else {
        anim.SetBool("Test", false);
    }

    if(Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.LeftArrow)){
        anim.SetBool("Left", true);
    } else {
        anim.SetBool("Left", false);
    }

    if(Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.RightArrow)){
        anim.SetBool("Right", true);
    } else {
        anim.SetBool("Right", false);
    }

    if(Input.GetKeyDown(KeyCode.UpArrow)){
        anim.SetTrigger("Jump");
        }
}
}
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
公共类角色:单一行为{
私人动画师;
公共层码头;
公众游戏者;
void Start(){
anim=GetComponent();
}
无效更新(){
如果(玩家,whatIsGround==0){
动画设置工具(“测试”,正确);
}否则{
动画设置工具(“测试”,错误);
}
if(Input.GetKey(KeyCode.RightArrow)| | Input.GetKey(KeyCode.LeftArrow)){
动画设置工具(“左”,真);
}否则{
动画设置工具(“左”,假);
}
if(Input.GetKey(KeyCode.LeftArrow)| | Input.GetKey(KeyCode.RightArrow)){
动画设置工具(“正确”,正确);
}否则{
动画设置工具(“右”,假);
}
if(Input.GetKeyDown(KeyCode.UpArrow)){
动画设置触发(“跳跃”);
}
}
}

如何解决此问题?

根据microsoft文档():

编译器错误CS1026

)期望

发现一个不完整的语句

这里有两个错误。首先,不能像这样将float转换为bool,然后在if结构的两个语句之间不能有“,”符号

我建议将“,”替换为“&&”或“| |”)并使用Player变量生成布尔表达式,如下所示:

  if(Player > 0 && whatIsGround == 0)

如果(Player,whatIsGround==0),你希望
做什么?你能详细说明一下你在这里想做什么吗?在所有的平台上,我都贴上了whatIsGround标签,如果玩家没有“看到”制作秋季动画的平台(在这个脚本中,这个脚本名为Test)为了更好地格式化,所有代码都应该按4个位置缩进:首先:为什么你的播放器是浮点型的?我可以想象一个播放器有一个playernumber,但这肯定只是一个
int
,而不是
float
。我不明白。无论如何,我假设你想要
if(player==0&&whatIsGround==0)
|
而不是
&
或…我不知道。如何
播放器,whatIsGround==0
可能是
真的
假的