Quantcast
Channel: Questions in topic: "framerate drops"
Viewing all articles
Browse latest Browse all 141

Script Is causing huge framerate drops

$
0
0
This is my script that opens and closes doors when i get close to the door the framerates drop to about 10 fps and i usually get about 90 fps when i not near. Is there something wrong with the script? i need help, thanks. using UnityEngine; using System.Collections; using UnityEngine.UI; public class Door : MonoBehaviour { private Animator Anim; [Header("Text")] public GameObject TextObject; public Text TextOnScreen; public MeshRenderer Key; public bool Locked; private bool UnLocked; [HideInInspector] public bool Opened; [HideInInspector] public bool InProximity; [Header("Audio")] public AudioClip DoorUnlock; private AudioSource AudSource; [HideInInspector] public bool Disabled; void Start() { AudSource = GetComponent (); Anim = GetComponent (); TextOnScreen.text = "OPEN"; if (Locked == false) { UnLocked = true; } } void OnMouseOver () { if (Anim.GetCurrentAnimatorStateInfo(0).IsName("Opening")) { TextOnScreen.text = "CLOSE"; } if (Anim.GetCurrentAnimatorStateInfo(0).IsName("Closing")) { TextOnScreen.text = "OPEN"; } if (Anim.GetCurrentAnimatorStateInfo(0).IsName("Idle")) { TextOnScreen.text = "OPEN"; } TextObject.SetActive(true); if (Locked == true) { if (UnLocked == false) { if (Key.enabled == true) { TextOnScreen.text = "UNLOCK"; if (Input.GetButtonDown ("Fire1")) { UnLocked = true; AudSource.clip = DoorUnlock; AudSource.Play (); } } else { TextOnScreen.text = "LOCKED"; } } } if (Opened == true) { TextOnScreen.text = "CLOSE"; } if (UnLocked == true) { if (Opened == true) { if (Input.GetButtonDown ("Fire1")) { CloseDoor (); } } if (Disabled == false) { if (TextOnScreen.text == "OPEN") { if (Input.GetButtonDown ("Fire1")) { OpenDoor (); } } } } } void OnMouseExit () { TextObject.SetActive (false); } public void CloseDoor() { Anim.SetTrigger ("Close"); Opened = false; } public void OpenDoor() { TextOnScreen.text = "CLOSE"; Anim.SetTrigger ("Open"); Opened = true; UnLocked = true; }

Viewing all articles
Browse latest Browse all 141

Trending Articles