This code will flip your gravity just put it on a gameobject and make it a trigger and also if you hit it again once flipped it will go back to normal :)
using System.Collections;
//Made by Troyy_ from troyyhelps.co.uk
using System.Collections.Generic;
//Made by Troyy_ from troyyhelps.co.uk
using UnityEngine;
//Made by Troyy_ from troyyhelps.co.uk
public class FlipGravity : MonoBehaviour
{
//Made by Troyy_ from troyyhelps.co.uk
private Vector3 originalGravity;
public Rigidbody rb;
public bool Flipped;
private int ALL = 0;
void Start()
{
Debug.Log("Made by Troyy_ from troyyhelps.co.uk");
originalGravity = Physics.gravity;
}
//Made by Troyy_ from troyyhelps.co.uk
private void OnTriggerEnter(Collider other)
{
if (Flipped)
{
if (ALL == 0)
{
StartCoroutine(DELAY());
Physics.gravity = originalGravity;
Flipped = false;
rb.transform.rotation = Quaternion.Euler(0f, rb.transform.rotation.eulerAngles.y, rb.transform.rotation.eulerAngles.z);
ALL = 1;
}
}
else
{
if (ALL == 0)
{
StartCoroutine(DELAY());
ALL = 1;
Flipped = true; Physics.gravity = new Vector3(Physics.gravity.x, -Physics.gravity.y, Physics.gravity.z); rb.transform.rotation = Quaternion.Euler(180f, rb.transform.rotation.eulerAngles.y, rb.transform.rotation.eulerAngles.z);
}
}
}
//Made by Troyy_ from troyyhelps.co.uk
IEnumerator DELAY()
{
yield return new WaitForSeconds(2f);
ALL = 0;
}
}
//Made by Troyy_ from troyyhelps.co.uk