Hey guys, having an issue where i have a very… very basic Task handler, so what happens is if the phone is ringing ‘isRinging = true;’ and i have a GUI that is asking if isRinging = true then to display this text, then another bool for is hasAnswered then to display the next task… for some reason the isRinging text still appears, blocking the view of half the next task. i did use to have this working, and dont remember changing anything to make it work otherwise, but now it is doing it and cant fix it… tried adding more statements into the if statement like && !hasAnswered but just keeps displaying the text. here is my code I’m trying to use, i know its messy, but thats what happens when something goes wrong and you do a heap of random shit to try and fix it… with no avail. even changed them from all if statements to else if and still no avail.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PhoneScript : MonoBehaviour {
public AudioSource phoneRinging;
public AudioSource phoneCall;
public BoxCollider boxCollider;
public Animator rampAnim;
public Animator switchAnim;
bool hasAnswered;
bool isRinging;
bool rampActivated;
// Use this for initialization
void Start () {
phoneRinging.enabled = true;
phoneCall.enabled = false;
hasAnswered = false;
isRinging = true;
rampAnim.enabled = false;
rampActivated = false;
switchAnim.enabled = false;
}
// Update is called once per frame
void Update () {
}
void OnGUI()
{
if (isRinging && !hasAnswered)
{
GUI.skin.label.alignment = TextAnchor.UpperLeft;
GUI.Label(new Rect(10, 10, 1000, 400), "Task: Answer The Phone.");
}else
if (hasAnswered && !isRinging)
{
GUI.skin.label.alignment = TextAnchor.UpperLeft;
GUI.Label(new Rect(10, 10, 1000, 400), "Task: Get to the boat and find a way to get your car off.");
}else
if (rampActivated)
{
GUI.skin.label.alignment = TextAnchor.UpperLeft;
GUI.Label(new Rect(10, 10, 1000, 400), "Task: Make your way around the island.");
}
}
public void answerPhone()
{
phoneRinging.enabled = false;
phoneCall.enabled = true;
isRinging = false;
hasAnswered = true;
boxCollider.enabled = false;
}
public void activateRamp()
{
rampAnim.enabled = true;
switchAnim.enabled = true;
rampActivated = true;
}
}