i have a script called gravity where i manage the current gravity direction checking booleans from 4 other scripts.whrn the player hits the obstacle,i want the game to restart and so i use appilcation.loadlevel but the value of these bools stays in the current state,which i don’t want.could use some help
here’s the script;
using UnityEngine;
using System.Collections;
public class gravity : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (right.rightShift) {
roof.roofShift=false;
floor.floorShift=false;
left.leftShift=false;
Physics2D.gravity=new Vector3(9.81f,0,0);
}
else if(left.leftShift) {
right.rightShift=false;
roof.roofShift=false;
floor.floorShift=false;
Physics2D.gravity=new Vector3(-9.81f,0,0);
}
else if(roof.roofShift) {
left.leftShift=false;
right.rightShift=false;
floor.floorShift=false;
Physics2D.gravity=new Vector3(0,9.81f,0);
}
else if(floor.floorShift) {
left.leftShift=false;
right.rightShift=false;
roof.roofShift=false;
Physics2D.gravity=new Vector3(0,-9.81f,0);
}
}
}
and this is one of the four scripts attached to the borders
using UnityEngine;
using System.Collections;
public class floor : MonoBehaviour {
// Use this for initialization
public static bool floorShift=false;
void Start () {
floorShift = false;
}
// Update is called once per frame
void Update () {
}
void OnMouseOver()
{
if(Input.GetMouseButton(0))
{
floorShift=true;
left.leftShift=false;
right.rightShift=false;
roof.roofShift=false;
}
}
}