I’m working on a 2D Plateformer. A mechanic in the game is that the gravity reverses when the player passes through a certain section of the level. On my player I have a script with the following function:
void OnTriggerEnter(Collider other)
{
switch (other.tag)
{
case "GravityDown":
Physics2D.gravity = new Vector2(0f, -9.81f);
Debug.Log("Gravity is Down");
break;
case "GravityUp":
Physics2D.gravity = new Vector2(0f, 9.81f);
Debug.Log("Gravity is Up");
break;
}
}
However I can’t get the trigger event to register when my player passes through the triggers. I’ve combed through tutorials and done/checked everything I could think of and it still doesn’t do anything. Also I’ve tested the gravity commands via certain inputs and they work just fine.