-2
嘿堆垛我得到了在C#中的IM幾個錯誤寫一個統一的遊戲 的錯誤是:團結3D錯誤C#
}
預期(約3倍)類型命名空間定義或文件結束預期(1次)
可能誤認爲空語句(2次)
無效表達術語 '> ='(1次)
不能隱式轉換型「浮動」到「布爾」(1次)
「對象」不包含「Runspeed」的定義,並沒有擴展方法「runspeed」接受類型的第一個參數「對象」可以找到(是否缺少using指令或程序集引用?)(1次)
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Playervitals : MonoBehaviour
{
public Slider healthslider;
public int maxHealth;
public int healthFallRate;
public Slider thirstslider;
public int maxThirst;
public int thirstFallRate;
public Slider hungerslider;
public int maxHunger;
public int hungerFallRate;
public Slider staminaslider;
public int maxstamina;
public int staminaFallRate;
public int staminaFallMult;
private int staminaRegainRate;
public int staminaRegainMult;
private CharacterController charcontroller;
private FPSInputController playercontroller;
void Start()
{
healthslider.maxValue = maxHealth;
healthslider.value = maxHealth;
thirstslider.maxValue = maxThirst;
thirstslider.value = maxThirst;
hungerslider.maxValue = maxHunger;
hungerslider.value = maxHunger;
staminaslider.maxValue = maxstamina;
staminaslider.value = maxstamina;
staminaFallRate = 1;
staminaRegainRate = 1;
charcontroller = GetComponent<CharacterController>();
playercontroller = GetComponent<FPSInputController>();
}
void Update()
{
//HEALTH CONTROL SECTION
if (hungerslider.value <= 0 && (thirstslider.value <= 0))
{
healthslider.value -= Time.deltaTime/healthFallRate * 2;
}
else if (hungerslider.value <= 0 || thirstslider.value <= 0)
{
healthslider.value -= Time.deltaTime/healthFallRate;
}
if (healthslider.value <= 0)
{
CharacterDeath();
}
//HUNGER CONTROL SECTION
if (hungerslider.value >= 0)
{
hungerslider.value -= Time.deltaTime/hungerFallRate;
}
else if (hungerslider.value <= 0)
{
hungerslider.value = 0;
}
else if (hungerslider.value >= maxHunger)
{
hungerslider.value = maxHunger;
}
//THIRST CONTROL SECTION
if (thirstslider.value >= 0)
{
thirstslider.value -= Time.deltaTime/thirstFallRate;
}
else if (thirstslider.value <= 0)
{
thirstslider.value = 0;
}
else if (thirstslider.value >= maxThirst)
{
thirstslider.value = maxThirst;
}
//Staminacontroller
if (charcontroller.velocity.magnitude > 0 && Input.GetKey(KeyCode.LeftShift)) ;
{
staminaslider.value -= Time.deltaTime/staminaFallRate * staminaFallMult; }
else
{
staminaslider.value += Time.deltaTime/staminaRegainRate * staminaRegainMult;
}
if (staminaslider.value >= maxstamina)
{
staminaslider.value = maxstamina;
}
else if (staminaslider.value <= 0) ;
{
staminaslider.value = 0;
{
staminaslider.value = 0;
playercontroller.m.Runspeed = playercontroller.m_walkspeed; }
else if (staminaslider.value) >= 0;);
{
}
playercontroller.m_runspeed = playercontroller.m_runspeednorm;
}
}
}
void CharacterDeath()
{
//DEATH
}
}
我希望你們能幫助我:)
您的代碼(後半段)是...呃...充滿了語法錯誤。 if語句之後的分號,孤立的大括號......你確定你不想再一次查看它了嗎? (Typos不是堆棧溢出的主題問題,因爲它們對未來的讀者有限制/沒有價值。) – Serlite
我知道的人,但聞一加布萊希特和刪除他,我得到88級的錯誤,而不是8:P。 – Matthias
檢查'如果(charcontroller.velocity.magnitude>'線和下面的'if'聲明不應該有一個';'後,如果您應該,但''{在一個新行'否則,如果(staminaslider.value <= 0)後,用分號一樣;',它刪除那麼爲什麼你打開另一''在'staminaslider.value = 0;'後的代碼後面加上'';''刪除它們。 –