Unity3d 需要帮助资产\FlyLittleBird.cs(7,27):错误CS1003:语法错误,'';预期
我正在unity中制作flappy bird,需要帮助这是我正在处理的代码,错误代码是Assets\FlyLittleBird.cs(7,27):错误CS1003:语法错误,,,,预期Unity3d 需要帮助资产\FlyLittleBird.cs(7,27):错误CS1003:语法错误,'';预期,unity3d,syntax-error,Unity3d,Syntax Error,我正在unity中制作flappy bird,需要帮助这是我正在处理的代码,错误代码是Assets\FlyLittleBird.cs(7,27):错误CS1003:语法错误,,,,预期 using System.Collections; using System.Collections.Generic; using UnityEngine; public class FlyLittleBird : MonoBehaviour { public float velocity -
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FlyLittleBird : MonoBehaviour {
public float velocity - 1;
private Rigidbody2D rb;
// Use this for initialization
void Start() {
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update() {
if(Input.GetMouseButtonDown(0))
{
// Jump
rb.velocity = Vector2.up * velocity;
}
}
}
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
公共类小飞鸟:单行为{
公众漂浮速度-1;
私有刚体2d rb;
//用于初始化
void Start(){
rb=GetComponent();
}
//每帧调用一次更新
无效更新(){
if(Input.GetMouseButtonDown(0))
{
//跳跃
rb.velocity=矢量2.up*速度;
}
}
}
在代码的第7行
i、 e.公共浮动速度-1;
你必须把它改正为-
公众漂浮速度=1
公共浮动速度-1代码>应该是公共浮动速度=-1代码>谢谢你的工作。请注意,明显的基于打字错误的问题是离题的,因为它不会在将来帮助任何人->谢谢你的工作。