Hello, I’m making a Flappy Bird game and I added the pause button the to the game. When I press the pause button the game is paused by Time.timeScale = 0; but if I press the jump button (in my case is the Space button) and then hit the resume button the bird jumps instantly when the game resumes. That means that the controller is still working while the pause is activated. How can I disable the controller?
This is the pause script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Pause : MonoBehaviour
{
Image img;
public Sprite playSprite;
public Sprite pauseSprite;
private void Start()
{
img = GetComponent<Image>();
}
public void OnPausedGame()
{
if(GameManager.gameIsPaused == false)
{
Time.timeScale = 0;
img.sprite = playSprite;
GameManager.gameIsPaused = true;
}
else
{
Time.timeScale = 1;
img.sprite = pauseSprite;
GameManager.gameIsPaused = false;
}
}
}
This is my controller script:
private void Update()
{
if (isDead == false)
{
if (Input.GetKey(KeyCode.Space))
{
rb2d.AddRelativeForce(Vector3.up);
}
}
}