Forum begins after the advertisement:


[Part 5] My SceneFader cannot function

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 5] My SceneFader cannot function

Viewing 3 posts - 21 through 23 (of 23 total)
  • Author
    Posts
  • #13752
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    Sorry, I don’t have money to open the paid forum, I am just learn from you guys, so if possible can you show the code that fix the bugs, thank you for your understanding

    #13753
    Joseph Tang
    Level 13
    Moderator
    Helpful?
    Up
    0
    ::

    Ah right, sorry about that, forgot the forum was locked. For the fix it’ll be; In the PlayerController.cs put the castOrHealTimer in the CastSpell() method instead of GetInputs(). This relocation ensures that the timer doesn’t reset when you release the Cast/Heal button before CastSpell() is called.

        void GetInputs()
        {
            xAxis = Input.GetAxisRaw("Horizontal");
            yAxis = Input.GetAxisRaw("Vertical");
            attack = Input.GetButtonDown("Attack");
    
            if (Input.GetButton("Cast/Heal"))
            {
                castOrHealTimer += Time.deltaTime;
            }
            else
            {
                castOrHealTimer = 0;
            }
        }
        void CastSpell()
        {
            if (Input.GetButtonUp("Cast/Heal") && castOrHealTimer <= 0.05f && timeSinceCast >= timeBetweenCast && Mana >= manaSpellCost)
            {
                pState.casting = true;
                timeSinceCast = 0;
                StartCoroutine(CastCoroutine());
            }
            else
            {
                timeSinceCast += Time.deltaTime;
            }
    
            if (!Input.GetButton("Cast/Heal"))
            {
                castOrHealTimer = 0;
            }
    
            if(Grounded())
            {
                //disable downspell if on the ground
                downSpellFireball.SetActive(false);
            }
            //if down spell is active, force player down until grounded
            if(downSpellFireball.activeInHierarchy)
            {
                rb.velocity += downSpellForce * Vector2.down;
            }
        }
    #13760
    Elvin Sim
    Level 10
    Participant
    Helpful?
    Up
    0
    ::

    Thank you!!!

Viewing 3 posts - 21 through 23 (of 23 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: