test i = 0; //only makes sense if ‘test’ is a type that can be set to 0
int i = 0; //an int is a type that can be set to 0 and used as a loop counter
All variable declarations use the following structure:
//type name = value
int num = 0;
Okay, now I changed the code to this IEnumerator RotateWheelLeft() { for (int i = 0; i = 50; i++) { //Stuff } } But I now get this error instead: Cannot implicitly convert type int' to bool'
Here's all the code using UnityEngine; using System.Collections; public class CarScript : MonoBehaviour { // Use this for initialization void Start () { StartCoroutine("RotateWheelLeft"); } public int g; IEnumerator RotateWheelLeft() { for (int i = 0; i < 50; i++) { g += 1; } } } Error: `CarScript.RotateWheelLeft()': not all code paths return a value
Uh, en dansker! Får du fejlen "not all code paths return a value"? I så fald: void RotateWheelLeft() { for (int i = 0; i < 50; i++) { // stuff } } Skal du skifte 'IEnumerator' ud med 'void'
for (int i = 0; i == 50; i++) {
// stuff
}
// You need to add two equals
This makes no sense, First you bumped a question that was asked over 7 years ago and has already been answered. Second using == in the condition doesn't make any sense since your loop wouldn't run at all. You set i to 0 and you only run your loop while i is 50 which is not the case to begin with so the loop isn't executed at all.
Okay, now I changed the code to this IEnumerator RotateWheelLeft() { for (int i = 0; i = 50; i++) { //Stuff } } But I now get this error instead: Cannot implicitly convert type
– AndreasX12int' tobool'It should be: for(int i = 0; i < 50; i++) (I think)
– FLASHDENMARKHmmm det bliver desværre heller ikke meget bedre af det :-)
– AndreasX12Here's all the code using UnityEngine; using System.Collections; public class CarScript : MonoBehaviour { // Use this for initialization void Start () { StartCoroutine("RotateWheelLeft"); } public int g; IEnumerator RotateWheelLeft() { for (int i = 0; i < 50; i++) { g += 1; } } } Error: `CarScript.RotateWheelLeft()': not all code paths return a value
– AndreasX12Uh, en dansker! Får du fejlen "not all code paths return a value"? I så fald: void RotateWheelLeft() { for (int i = 0; i < 50; i++) { // stuff } } Skal du skifte 'IEnumerator' ud med 'void'
– FLASHDENMARK