- Home /
Question by
theas00 · Sep 01, 2020 at 09:55 AM ·
scripting probleminputunity5player movement
how to disable player inputs?
I would like to disable player controls when it enters an area with a trigger!
Comment
Answer by ShadyProductions · Sep 01, 2020 at 10:38 AM
Here is some rough pseudo code, but it should point you in the right direction.
public static bool PlayerControlsDisabled = false;
private void OnTriggerEnter(Collider other)
{
PlayerControlsDisabled = true;
}
private void OnTriggerExit(Collider other)
{
PlayerControlsDisabled = false;
}
You can then in your PlayerControls check if the bool is true or not
if (yourscriptname.PlayerControlsDisabled == false)
{
// Player controls in here
}
Your answer
Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Camera script for ball not working as intended, looking for some tips, or advise. 0 Answers
enable and disable loop objects in the scene 1 Answer
Player alignment with Terrain 1 Answer
Baffling Input.Mouseposition problem. If statement not correctly working. 1 Answer