I want to make a gravity changer with trigger enter. This is the code;
void OnTriggerEnter (Collider other) {
if (GetComponent<Collider>().tag == "Player") {
gravity.x = 0;
gravity.y = -10;
gravity.z = 0;
its working well but when the player went out of the collider, it continues forever. I want to disable it when the player is out. I tried also this;
void OnTriggerStay (Collider other) {
if (GetComponent<Collider>().tag == "Player") {
gravity.x = -10;
gravity.y = 0;
gravity.z = 0;
}
}
void OntriggerExit(Collider other){
if (GetComponent<Collider> ().tag == "Player") {
gravity.x = 0;
gravity.y = -10;
gravity.z = 0;
but result is same. So can you help me to make what i want to do?