C# 统一运动脚本中的地面检测赢得';行不通

C# 统一运动脚本中的地面检测赢得';行不通,c#,unity3d,scripting,game-development,C#,Unity3d,Scripting,Game Development,我的团结计划需要帮助。我是gamedev的新手,为了学习一些基础知识,我决定对mario游戏进行暴力破解。然而,我一直在忙于制作一个动作脚本。我轻松地想出了如何让我的马里奥角色左右移动,但我在跳跃方面遇到了麻烦。我可以跳,但我就是不知道如何对它进行地面探测。我会包括一些代码示例,但我已经尝试了很多东西,我甚至不知道我会包括什么。请花点时间帮我粘贴一个链接到你的动作脚本的副本,这样我就可以很有希望地完成这项工作。谢谢 编辑: 它仍然不起作用,我真的不知道为什么 这是我的密码: 使用系统集合; 使用

我的团结计划需要帮助。我是gamedev的新手,为了学习一些基础知识,我决定对mario游戏进行暴力破解。然而,我一直在忙于制作一个动作脚本。我轻松地想出了如何让我的马里奥角色左右移动,但我在跳跃方面遇到了麻烦。我可以跳,但我就是不知道如何对它进行地面探测。我会包括一些代码示例,但我已经尝试了很多东西,我甚至不知道我会包括什么。请花点时间帮我粘贴一个链接到你的动作脚本的副本,这样我就可以很有希望地完成这项工作。谢谢

编辑: 它仍然不起作用,我真的不知道为什么 这是我的密码:

使用系统集合;
使用System.Collections.Generic;
使用System.Security.Cryptography;
使用UnityEngine;
公共课马里奥:单一行为
{
刚体2d rb;
动画师;
喷洒器;
布尔按钮;
布尔被禁足;
[序列化字段]
浮动速度;
[序列化字段]
浮力;
void Start()
{
rb=GetComponent();
animator=GetComponent();
spriteender=GetComponent();
}
void FixedUpdate()
{
IsGround=Physics2D.Linecast(_transform.position、GroundChecker.position、whatIsFloor);
if(Input.GetKey(“right”)| | Input.GetKey(“left”)| | Input.GetKey(“up”))
{
pushingButton=true;
}
其他的
按钮=错误;
if(Input.GetKey(“左”)&Input.GetKey(“右”))
{
动画师。播放(“马里奥空闲”);
rb.velocity=新矢量2(0,0);
}
else if(Input.GetKey(“right”)和&Input.GetKey(“up”))
{
动画师。播放(“马里奥跳跃”);
spriterenderer.flipX=false;
rb.velocity=新矢量2(速度,rb.velocity.y);
}
else if(Input.GetKey(“right”))
{
动画师。播放(“马里奥漫步”);
spriterenderer.flipX=false;
rb.velocity=新矢量2(速度,rb.velocity.y);
}
if(Input.GetKey(“左”)&Input.GetKey(“右”))
{
动画师。播放(“马里奥空闲”);
rb.velocity=新矢量2(0,0);
}
else if(Input.GetKey(“左”)和&Input.GetKey(“上”))
{
动画师。播放(“马里奥跳跃”);
spriterenderer.flipX=true;
rb.velocity=新矢量2(-speed,rb.velocity.y);
}
else if(Input.GetKey(“左”))
{
动画师。播放(“马里奥漫步”);
spriterenderer.flipX=true;
rb.velocity=新矢量2(-speed,rb.velocity.y);
}
if(Input.GetKeyDown(“up”)和&isground)
{
动画师。播放(“马里奥跳跃”);
rb.velocity=新矢量2(rb.velocity.x,跳跃力);
isfounded=false;
}
如果(按钮==错误)
{
动画师。播放(“马里奥空闲”);
rb.velocity=新矢量2(0,rb.velocity.y);
}
}
}
创建一个游戏对象“地面检查”,使其成为角色的子对象,并将其放置在角色的脚下 //LayerMask,用于确定玩家的场地 公共层码头

// Transform just below feet for checking if player is grounded
public Transform groundCheck;

void Update()
{

    /* Check to see if character is grounded by raycasting from the middle of the player down to the groundCheck position and see if collected with gameobjects on the whatIsGround layer */

    isGrounded = Physics2D.Linecast(_transform.position, groundCheck.position, whatIsGround);

    // If grounded AND jump button pressed, then allow the player to jump

    if (isGrounded && CrossPlatformInputManager.GetButtonDown("Jump")) 
    {
        DoJump();
    }
}

我们无法回答这个问题,除非你向我们展示你目前拥有的代码,无论代码有多坏,因为我们不知道你是如何在游戏中实现玩家移动的。