The issue relies on TIME, it detects the jump (action input) first, and later detects the pause (pause input) on the UI element (pause button).. I fix this by checking a boolean variable before triggering the jump (action input) and on the pause script, delaying by a fraction of a second when this variable is re enabled... this is how it works for me:
Action Script:
public class PlayerController : MonoBehaviour {
static public bool pauseCheck=true;
void Update()
{
if(Input.GetMouseButtonDown(0) pauseCheck ==true)
{
jump = true;
}
}
}
and Pause Script:
public class Pause : MonoBehaviour {
static public bool paused = false;
void OnMouseDown() {
paused = !paused;
PlayerController .pauseCheck =false ;
if(paused){
Time.timeScale = 0;
}
else{
Time.timeScale = 1;
StartCoroutine (pause());
}
}
IEnumerator pause()
{
yield return new WaitForSeconds(0.1f);
PlayerController .pauseCheck =true;
}
}
Hope this help.
↧