每次我尝试打开游戏时都会发生这种情况
Assets / enemy_health.cs(32,119):错误CS1001:意外的符号`)',期待标识符
我找不到答案。
PS不仅是这个,还包括其他类似的;
using System.Collections;
using UnityEngine;
public class enemy_health : MonoBehaviour
{
public float max_Health = 100f;
public float cur_Health = 0f;
public GameObject Healthbar;
// Use this for initialization
void Start ()
{
cur_Health = max_Health;
InvokeRepeating("decreasehealth",1f,1f);
}
// Update is called once per frame
void Update () {
}
void decreasehealth()
{
cur_Health -= 2f;
float calc_Health = cur_Health / max_Health;
SetHealthBar (calc_Health);
}
public void SetHealthBar (float myHealth);
//myHealth value0-1
Healthbar.transform.localScale new Vector3 (myHealth.Healthbar.transfor.localScale.y.Healthbar.transform.localScale.z);
}
}
答案 0 :(得分:1)
您对SetHealthBar
的定义格式不正确。它应该如下。将其与其他函数的定义进行比较。
public void SetHealthBar (float myHealth) <-- note the missing semicolon ';'
{ <-- and the opening bracket
//myHealth value0-1
Healthbar.transform.localScale = new Vector3 (myHealth.Healthbar.transfor.localScale.y.Healthbar.transform.localScale.z);
// also don't forget to actually assign your variable, note the equals sign above
}