Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys, I need help with animation playing whenever UI button in pause menu is clicked in Unity 3D, that is, when left-click of a mouse is cliked, the character in the game plays attack animation but the animation also plays when I click resume button again with left-click of the mouse in pause menu. The question is how is it possible to ensure that attack animation is not played after I click resume button. The similar problem happens when the player enters a trigger there appears a UI panel containing buttons and when one of those buttons are clicked again attack animation is played and I do not want to let that happen. Down below is th code I am using:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PauseMenu : MonoBehaviour
{

    public static bool IsPaused = false;
    public GameObject pauseMenuUI;
    public GameObject Player;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
          
            if (IsPaused)
            {
                Resume();
            }
            else
            {
                Pause();
            }
        }
        
        
           
        
    }
    public void Resume()
    {
        pauseMenuUI.SetActive(false);
        Time.timeScale = 1f;
        IsPaused = false;
       

    }

    void Pause()
    {
        pauseMenuUI.SetActive(true);
        Time.timeScale = 0f;
        IsPaused = true;
       
    }

  

    public void QuitGame()
    {

    }

    public void MainMenu()
    {
        Application.Quit();
    }
}


What I have tried:

I tried to use setrigger and resettrigger
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900