can someone help me with fixing these scripts
public Slider WidthSlider;
public GameObject tile;
public GameObject end;
public int width = 10;
public int length = 10;
List<GameObject> level;
// Use this for initialization
void Start () {
level = new List<GameObject> ();
CreateLevel (width, length);
}
public void ClearLevel()
{
int numberOfTiles = level.Count;
while (numberOfTiles > 0) {
Destroy (level [0]);
level.RemoveAt (0);
numberOfTiles = numberOfTiles - 1;
}
}
public void Rebuild()
{
CreateLevel (width, length);
}
public void GetWidth()
{
length = Mathf.FloorToInt(WidthSlider.value);
}
public void CreateLevel(float Width, float Length)
{
ClearLevel ();
for (int x = 0; x < Width; x = x + 1) {
for (int z = 0; z < Length; z = z + 1) {
GameObject newTile = Instantiate (tile);
Vector3 newPosition = transform.position +new Vector3 (x, 0, -z);
newTile.transform.position = newPosition;
level.Add (newTile);
}
}
GameObject newEnd = Instantiate (end);
Vector3 endPosition = transform.position +new Vector3 (Mathf.CeilToInt(Width/2)-0.5f, 0, -(Length+5)+0.5f);
newEnd.transform.position = endPosition;
newEnd.transform.localScale = new Vector3 (Width, 1, 10);
level.Add (newEnd);
}
// Update is called once per frame
void Update () {
}
} /// script 2 using UnityEngine; using System.Collections;
public class RandomColor : MonoBehaviour {
Material myMaterial;
public Color currentColor = Color.green;
float nextSwitch = 0;
public int thing = 0;
public Collider BlackCollider;
public float switchTime = 3;
// Use this for initialization
void Start () {
MeshRenderer myRender = GetComponent<MeshRenderer> ();
myMaterial = Instantiate (myRender.material);
myRender.material = myMaterial;
myMaterial.color = currentColor;
}
// Update is called once per frame
void Update () {
if (Time.time > nextSwitch) {
nextSwitch = Time.time + switchTime;
currentColor = NewColor();
myMaterial.color = NewColor();
}
}
Color NewColor (){
float dice = Random.value;
int choice = 0;
if (dice > 0.85f) {
choice = 1;
} else if (dice > 0.8f){
choice = 2;
} else if (dice > 0.7f){
choice = 3;
}
thing = choice;
//Random.Range (0, 5);
switch (choice) {
case 0:
BlackCollider.enabled = false;
return Color.red;
break;
case 1:
BlackCollider.enabled = true;
return Color.black;
break;
case 2:
BlackCollider.enabled = false;
return Color.blue;
break;
case 3:
BlackCollider.enabled = false;
return Color.green;
break;
case 4:
BlackCollider.enabled = false;
return Color.yellow;
break;
case 5:
return Color.magenta;
break;
}
return Color.white;
}
} // script 3 using UnityEngine; using System.Collections;
public class ColorEffect : MonoBehaviour {
// Use this for initialization
void Start () {
}
void OnCollisionEnter(Collision col)
{
RandomColor colorCube = col.gameObject.GetComponent<RandomColor> ();
if (colorCube != null) {
if (colorCube.thing == 2) {
BlueEffect ();
}
if (colorCube.thing == 3) {
GreenEffect ();
}
}
}
// Update is called once per frame
void Update () {
}
void BlueEffect(){
this.transform.position = this.transform.position - (Vector3.forward*4);
Debug.Log("BLUE");
}
void GreenEffect(){
this.transform.position = this.transform.position + (Vector3.forward*4);
Debug.Log("You Dead bro");
}
void RedEffect(){
}
} // script 4 using UnityEngine; using System.Collections;
public class PlayerWalk : MonoBehaviour {
public float speed;
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = (transform.right*moveHorizontal) + (transform.forward*moveVertical);
rb.AddForce (movement * speed);
}
}
I would suggest rena$$anonymous$$g the variable "thing" to "entity" and the variable "width" to "tomatoJuiceCoefficient". Everything else looks fine to me.
Or did you mean by "fixing" that there are errors in the script / they are not doing what you want them too? Then please, be so incredibly kind to explain your problem precisely and maayyybee pleeaase even use the code-tags for the source code correctly so they are more readable.
Your answer
Follow this Question
Related Questions
ERROR CS 1525 Please help me!! 1 Answer
What i can do with Type Load Exception Unity3d 0 Answers
c# Unreachable code detected 2 Answers