- Home /
using "for" in Unity Script HELP!
for (int i = 0; i < waypoint.Length; i++)
{
Gizmos.DrawLine(waypoint[i].transform.position, waypoint[i++].transform.position);
}
when using that in UnityScript(JS) I get an error saying
Assets/WaypointSystem.js(61,18): BCE0044: expecting ;, found 'i'.
Answer by efge · Feb 22, 2011 at 11:28 PM
In JS it should be:
for (var i : int = 0; i < waypoint.Length; i++)
Answer by FearMePanda · Jan 19, 2012 at 07:17 AM
this is the c# version of the code you were writing
for (int i = 0; i < waypoint.Length; i++) { Gizmos.DrawLine(waypoint[i].transform.position, waypoint[i].transform.position); }
the error you got was because of the i++ instead of the i in: Gizmos.DrawLine(waypoint[i].transform.position, waypoint[i++]waypoint[i++].transform.position);
Your answer
Follow this Question
Related Questions
Having Trouble with this For Loop 1 Answer
FPS Script Error OnCollisonEnter 1 Answer
How to handle long loops 3 Answers
Unity MoveAround error 1 Answer
Unity3d C to Javascript conversion? 1 Answer