Forum begins after the advertisement:


[Part 9] Pause Menu when resume don’t take input anymore

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 9] Pause Menu when resume don’t take input anymore

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16369
    pepecry
    Level 6
    Participant
    Helpful?
    Up
    0
    ::

    So i was making the pause menu, the quit to main menu and other function look good. But the thing is when I pause the game and click the resume button. I cannot move my character anymore, even attack or healing.
    Resume button assign

    private void Update()
    {
        if(Input.GetKeyDown(KeyCode.P))
        {
            SaveData.Instance.savePlayerData();
        }
        if (Input.GetKeyDown(KeyCode.Escape) && !gameIsPause)
        {
            pauseMenu.fadeUIIn(fadeTime);
            Time.timeScale = 0;
            gameIsPause = true;
        }
    }
    
    public void unpauseGame()
    {
        Time.timeScale = 1;
        gameIsPause = false;
    
    }

    I already put the if(GameManager.Instance.gameIsPause) return; in the enemy and player. Here the enemy

    protected virtual void Update()
    {
    
        if(GameManager.Instance.gameIsPause) return;
    
        if (isRecoilling)
        {
            if (recoinTimer < recoilLength)
            {
                recoinTimer += Time.deltaTime;
            }
            else
            {
                isRecoilling = false ;
                recoinTimer = 0 ;
            }
        }
        else
        {
            UpdateEnemyStates();
        }
        
    }

    and here is the player

    private void Update()
    {
        if (GameManager.Instance.gameIsPause) return;
        if (playerStateList.incutscene) return;
    
        if(playerStateList.alive)
        {
            getInput();
            OpenMap();
            OpenInventory();
        }
        UpdateJump();
        RestoreTimeScale();
        if (playerStateList.dashing) return;
        FlashWhenInvi();
        if (playerStateList.alive){
    
            if (!iswallJumping)
            {
                Moving();
                Flip();
                Jump();
            }
        };
        Heal();
        CastSpell();
        if (playerStateList.healing) return;
    
        if (unlockWalljump)
        {
            WallSlide();
            WallJump();
        }
        if (unlockDash)
        {
            StartDash();
        }
        Attack();
    }

    Is this error cause because of the potion of the if statement in the player script?

    #16414
    Chloe Lim
    Level 9
    Moderator
    Helpful?
    Up
    1
    ::

    Try calling the unpause function then the fade time, it might be possible that the fade time is calling delta time and it won’t be completed for the game to be unpaused
    try putting the fadeUIout within the unpause game function

        public void UnpauseGame()
        {
            Time.timeScale = 1;
    pauseMenu.FadeUIOut(fadeTime);
            gameIsPaused = false;
        }

    then just call for unpausegame in the Onclick() for resume

    has upvoted this post.
    #16420
    pepecry
    Level 6
    Participant
    Helpful?
    Up
    0
    ::

    So i tried as you said. But it doesn’t solve the problem. When I click the resume. All the thing still can move like the boss but my character cannot get my input. I cannot attack or doing anything as the below record.
    Resume error
    And I also want to as you for another question. My boss when doing the dive attack, he only create 1 pillar instead of many like in the video, and the pillar when spawn is spawning in some very weird location. Also the pillar will one hit me because it deal multiple time damage to player in a very shot time. Could said in every frame of the animation. Can you help me fix this?

    #16446
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Can you show us the GetInputs() function in your script?

    Edit: Double click on the ArgumentNullException in your Console and show us the highlighted line as well.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: