how can i invert player movement controls in game using a trigger box

hi i have been trying to use a trigger box to invert my players controls when entering and then change them back when leaving the trigger box im new to coding so dont know to much any help would be helpful

In a script you can use the MonoBehaviour voids
OnCollisionEnter () {
if (collisionInfo.gameObject.transform.name == “nameHere”) {
movementMultiplyer = 1;
}
}

OnCollisionExit (Collision collisionInfo) {
        if (collisionInfo.gameObject.transform.name == “nameHere”) {
                  movementMultiplyer = -1;
         }
}

On your movement part of whatever script of yours handles that, just times it by -1 or by 1 depending on weather you want the controls to be inverted or not. Btw if you’re using 2D, you can do OnCollisionEnter/Exit2D with the 2D and change the collision to Collision2D and this should work. Just access this variable in your script and times all movement by this movementMultiplyer. You will need to declare the movementMultiplyer at the start of the script as an int.

Hope this helps :slight_smile: