The question is answered, right answer was accepted
Help! my script won't load, cant find the error?
Hello,
im a bit of a beginner in unity, everything was going fine but now my script wont load anymore, its says that there is no monobehaviour or that the name is not correct, but i can't see where the error is.
Could someone please help me out?
using UnityEngine; using System.Collections.Generic;
public class Test : MonoBehaviour {
public GameObject cube;
public int amount;
public int minL, minR, maxL, maxR;
// Use this for initialization
void Start () {
PlaceCubes ();
}
void PlaceCubes(){
List<Vector3> occupied = new List<Vector3> ();
while (occupied.Count <= amount) {
int x, y, z, random1, random2;
random1 = UnityEngine.Random.Range (0, 3);
random2 = UnityEngine.Random.Range (0, 3);
Debug.Log(random1);
Debug.Log(random2);
if (random1 == 1 && random2 == 1) {
x = UnityEngine.Random.Range (minL, maxL);
y = 1;
z = UnityEngine.Random.Range (minL, maxL);
}
if (random1 == 1 && random2 == 2) {
x = UnityEngine.Random.Range (minL, maxL);
y = 1;
z = UnityEngine.Random.Range (minR, maxR);
}
if (random1 == 2 && random2 == 1) {
x = UnityEngine.Random.Range (minR, maxR);
y = 1;
z = UnityEngine.Random.Range (minL, maxL);
}
if (random1 == 2 && random2 == 2) {
x = UnityEngine.Random.Range (minR, maxR);
y = 1;
z = UnityEngine.Random.Range (minR, maxR);
}
Vector3 Location = new Vector3 (x, y, z);
if (!occupied.Contains (Location)) {
occupied.Add (Location);
Debug.Log(occupied.Count);
}
}
for (int i = 0; i < amount; i++) {
Vector3 V = (Vector3)occupied[i];
Instantiate (cube, V, Quaternion.identity);
}
}
bool equals(Vector3 thiy, Vector3 that)
{
return thiy.x == that.x && thiy.z == that.z;
}
}
P.s. its probably full of stupid errors, but it did work when it was just placing 30 random cubes for me, things went wrong after i implemented the while loop.
many thanks!
Just found out that all my other scripts in the project wont load anymore, even the ones in other scene's which i didn't even touch. How can this be?
Follow this Question
Related Questions
Multiple in game currencies 1 Answer
Using LookAt to look at a Vector3 not Transform 0 Answers
there MonoBehaviour script data type? 1 Answer
How to make a shooting bow? 0 Answers
The roll a ball script isn't working 3 Answers