谁能解释一下为什么我不能使用这个条件?
private void OnTriggerStay(Collider other)
{
if (other.name == "healerTriger")
Healing();
}
void Healing()
{
takingDmg = false;
do
{
hpPlayer = 1 * Time.deltaTime;
}
while (hpPlayer< 50);
}
即使有如果或当条件崩溃统一,但为什么?这里有个限制....
这是你的问题
void Healing()
{
takingDmg = false;
do
{
hpPlayer = 1 * Time.deltaTime; // this does not increate and you are staying in an infinite loop
}
while (hpPlayer< 50);
}
应该改成
void Healing()
{
takingDmg = false;
do
{
hpPlayer += 1 * Time.deltaTime; // just put a "+" in here
}
while (hpPlayer< 50);
}