Hi, so I wrote this piece of code to my project and when Shield is true, in tha game the game freezes and the only way to unfreeze is to fore quit unity, so what tf did I did? Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class Hands : MonoBehaviour { public Transform ManaBar; public bool Shield; public Animator MyAnimator; IEnumerator WaitAndPrint() { yield return new WaitForSeconds(0.1f); ManaBar.localScale -= new Vector3(0.1f, 0f, 0f); } // Start is called before the first frame update void Start() { MyAnimator = GetComponent<Animator>(); } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(1)) { Shield = true; } while (Shield == true) {WaitAndPrint(); } MyAnimator.SetBool("Shield", Shield); } }
You've got an infinite while loop there. It's just running that bit of code endlessly. Unity Editor doesn't cope at all well with infinite loops. Also, I'd never personally put a while loop inside Update.