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);
}
}
}
↧