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

getting loop errors, need help

$
0
0
Im experimenting with loops and am getting errors such as "Assets/Loops.cs(36,22): error CS0103: The name `i' does not exist in the current context" any ideas why? using UnityEngine; using System.Collections; public class Loops : MonoBehaviour { public class Target {//start class definition // properties public int id; public string type; public string name; public int lvl; public int health; // A Method public void targetInfo () { print("unit: " + id); print("ID: " + name); print("class: " + type); print("level: " + lvl); print("health: " + health); } } //end of class definition //------------------------------- // Use this for initialization void Start () { Target[] unit = new Target[51];//create array for (int i = 1; i <= 50; i++); { unit[i] = new Target();//instantiating 50 objects unit[i].id = i; unit[i].type = "Merc"; unit[i].name = "Yuri"; unit[i].lvl = 12; unit[i].health = 200; } for (int i = 1; i <= 10; i++); { unit[i].targetInfo(); } } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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