unity3d - 为什么这会给我一个错误,在类、结构或接口成员声明中说意外符号“1”
问题描述
我制作了一个游戏,这个游戏突然出现了
我从其他地方看,没有找到答案
唱 UnityEngine;使用 System.Collections;
公共课 pyssy : MonoBehaviour {
public int bulletsPerMag = 30;
public int bulletsLeft;
public float fireRate = 0,1f;
float fireTimer;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButton("Fire1"))
{
Fire();
}
if (fireTimer < fireRate)
fireTimer += Time.deltaTime;
}
private void Fire()
{
if (fireTimer < fireRate) return;
Debug.Log("shot!")
}
}
应该管用
解决方案
public float fireRate = 0,1f;
对于浮点值,您应该使用点而不是逗号。编程中的逗号用于分隔不同的值。
将其更改为public float fireRate = 0.1f;
并给你一个提示。当您遇到unexpected symbol/character
错误或类似情况时,通常意味着它要么是拼写错误,要么是没有正确结束的行。至少我有好几次都是这样!
推荐阅读
- python - ODBC for SQL Server in Python
- java - Is it possible to test a java-based CRUD without using Spring Boot JPA?
- php - PHP mysql按键排序JSON数据
- html - Shopify - 公告栏更新
- c++ - 为什么这两个简单的循环都不是无限的?
- cognos-10 - 任何人都有使用 Cognos 甘特图的经验?
- ios - 为什么 GeometryReader 的主体会被评估两次?也是第一次尺寸为零?
- python - 我在 python 中实现分发时遇到了麻烦
- c# - 如何在 UWP 应用中发送内部通知?
- shell - 如何从 shell 脚本调用 deno?