简体   繁体   English

错误 CS1022:类型或命名空间定义,或文件结尾预期的统一 3d 游戏引擎

[英]error CS1022: Type or namespace definition, or end-of-file expected unity 3d game engine

I have this script file我有这个脚本文件

using UnityEngine;

public class playermove : MonoBehaviour{
public float moveSpeed=5f;}


    // Update is called once per frame
    void Update(){
        jump();
       Vector3 movment = new Vector3(Input.GetAxis("Horizontal"),0f ,0f);
       transform.position += movment * Time.deltaTime * moveSpeed; 
    }
    void jump() {
        if (Input.GetButtonDown("jump"));
        gameObject.GetComponent<RigidBody2D>();AddForce(new Vector2(0f,5f),ForceMode2D.Impulse);
    }

}

}

And I am getting this error:我收到此错误:

error CS1022: Type or namespace definition, or end-of-file expected unity 3d game engine错误 CS1022:类型或命名空间定义,或文件结尾预期的统一 3d 游戏引擎

Your coding file has a bracket issue.您的编码文件有括号问题。

 public float moveSpeed=5f;}

It should be like this:应该是这样的:

using UnityEngine;

public class playermove : MonoBehaviour
{
    public float moveSpeed = 5f;


    // Update is called once per frame
    void Update()
    {
        jump();
        Vector3 movment = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);
        transform.position += movment * Time.deltaTime * moveSpeed;
    }
    void jump()
    {
        if (Input.GetButtonDown("jump")) ;
        gameObject.GetComponent<RigidBody2D>(); AddForce(new Vector2(0f, 5f), ForceMode2D.Impulse);
    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Unity 显示“错误 CS1022:类型或命名空间定义,或预期的文件结尾” - Unity says "error CS1022: Type or namespace definition, or end-of-file expected" 错误CS1022:类型或名称空间定义,或预期的文件结尾 - error CS1022: Type or namespace definition, or end-of-file expected 我遇到消息错误 CS1022: Type or namespace definition, or end-of-file expected - I'm having a problem with the message error CS1022: Type or namespace definition, or end-of-file expected C# 错误:cs(22,1):错误 CS1022:类型或命名空间定义,或预期文件结尾 - C# Error : cs(22,1): error CS1022: Type or namespace definition, or end-of-file expected Assets\\Scripts\\InGamePanel.cs(6,1):错误 CS1022:类型或命名空间定义,或预期的文件结尾 - Assets\Scripts\InGamePanel.cs(6,1): error CS1022: Type or namespace definition, or end-of-file expected 错误 CS1513:} 预期和 CS1022:预期文件结束 - 但文件对我来说看起来不错 - Error CS1513: } expected & CS1022: End-of-file expected - But file looks fine to me Unity 给出“类型或命名空间定义,或预期文件结尾”错误 - Unity gives “Type or namespace definition, or end-of-file expected” error 类型或命名空间定义,或预期的文件结尾 (22,1) (UNITY) - Type or namespace definition, or end-of-file expected (22,1) (UNITY) 类型或名称空间定义,或预期的文件结尾 - Type or namespace definition, or end-of-file expected Unity C# 错误:“类型或命名空间定义,或预期文件结尾” - Unity C# Error: “Type or namespace definition, or end-of-file expected”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM