ใน sudan. kgm ได้ยังไงฉันหยุด perpetual คณิตศาสตร์การให้สอบสวน?

0

คำถาม

คำถามคือแบบง่ายๆแต่ฉันไม่สามารถสำหรับชีวิตของฉันหาทางออกได้

ฉันตรรกะเกิดขึ้นแบบนี้

// Static floats are StatBase.maxHealth = 0 and rStat.maxHealth = 70

class rStat : Monobehaviour
{

    
    public bool nomatter = false;

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            nomatter = true;
        }


        if (nomatter == true)
        {
            healthcalc();
        }

        void healthcalc()
        {
         StatBase.maxHealth += rstat.maxHealth; // StatBase.maxHealth should = 70 but the 
                                                // number never stops adding

         nomatter = false;

        }
    }
}
c# if-statement static unity3d
2021-11-24 04:05:05
1

คำตอบที่ดีที่สุด

0

จะต้องยอมรับความจริงว่าตรรกะค่อนข้างแปลก

ทำไมเรื่องนี้ bool ธงนั้นถ้าคุณ ต้อง หนึ่งคุณต้องการที่จะทำอยู่? คุณสามารถเพียงทำ

void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        healthcalc();
    }
}

// in general rather put this on class level and don't nest it under Update
void healthcalc()
{
     StatBase.maxHealth += rstat.maxHealth; 
}

หรือถ้ามีเพียงหนึ่งเส้นยังไงแม้แต่

void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        StatBase.maxHealth += rstat.maxHealth;
    }
}
2021-11-24 08:08:45

คลิกเม้าส์ไม่ใช่ส่วนหนึ่งของจริงตรรกะ. ในเกมที่เล่นจะทำการคลิกปุ่มเหมือนคำว่า"ยอมรับ"เพื่อ allocate เป็นสถิติประเด็นซึ่งจะเพิ่มมันสถิติจำนวนเงิน ปัญหาของฉันนั่นมันอยู่ในวิธีการปรับปรุงดังนั้นมันไม่สำคัญอย่างที่ฉันกำลังทำอะไรมันก็มักจะเป็น actively เพิ่ม. ขอบคุณสำหรับคำตอบแม้ว่าฉันขอบคุณที่ช่วยด้วย
joe pace

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่