Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Script crashing all scripts?(not solved)

$
0
0
Basically, The title says it all. So, I made a script called magic switching. And I based it off a another script I had, which is weapon switching, which I would like to mention works perfectly fine. Like, I have no problems with it at all. So when I made magic switching all hell broke loose. I just thought it was unity but nope it's the script(I made a copy of a backup. Attached the MagicSwitching Script to it and that went berserk too). What happens is that, console just goes bye bye, I can't attach any script to anything! And by anything I mean anything. No script will work. Then some of the game objects can't read scripts so that happens. So it's basically one big error. Why is this happening! Help! Here is the script in case you need it using UnityEngine; using System.Collections; public class MagicSwitching : MonoBehaviour { public GameObject[] MagicStuffs; public int currentMagicStuff = 0; void Start() { nrMagicStuffs = MagicStuffs.Length; SwitchMagic(currentMagicStuff); } void Update () { for (int i=1; i <= nrMagicStuffs; i++) { if (Input.GetKeyDown ("" + i)) { currentMagicStuff = i - 1; SwitchMagic (currentMagicStuff); } } } void SwitchMagic(int index) { for (int i=0; i < nrMagicStuffs; i++) { if (i == index) { MagicStuffs[i].gameObject.SetActive(true); } else { MagicStuffs[i].gameObject.SetActive(false); } } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>