[英]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.