- Home /
How do I stop the player moving and looking around when UI appears?
I basically want to stop the player doing anything when the UI appears of the bottom of this script:
public static int NumNotesRemaining = 0;
public GameObject NotesFoundPanel;
// Start is called before the first frame update
void Start()
{
NumNotesRemaining += 1;
}
void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Player")) return;
NumNotesRemaining -= 1;
gameObject.SetActive(false);
if(NumNotesRemaining <= 0)
{
NotesFoundPanel.SetActive(true);
}
}
Where I make the UI appear I need to disable player movement so that the player can click to remove the UI, then I need to player movement to be enabled again.
You don't say how the movement is working? Is it mouse / game controller / keyboard / swipe / breath sensor / treadmill / VR motion sensors... You also don't mention whether its 2D / 3D. The above may seem silly, but its important to know as much detail about what you are trying to achieve, what you have tried so far and finally what you require assistance with. The answer by @Abdu_$$anonymous$$i could be the perfect answer - but it could also be completely wrong. For instance, assume you are using a First Person Controller in 3D, you'd just want to disable the character controller whilst you have UI on screen, leaving the timescale running to allow bad guys to wander around and sneak up on you.
Answer by Abdu_Ki · Apr 24, 2019 at 07:41 PM
You could set the timescale to 0 while the UI is showing and set it back to 1 when the UI disappears.
The timescale option worked great but still allows the player to look around. Is there a way around this?