Original Post
I'm trying to declare a string and then use it later in the script.
string directionG;//global declaration In the main loop I do: directionG = "right";//default declaration Then in a function (that I later use in the main loop): static float indexX = -1.0f;
static float indexY = -0.3f;
static float indexZ = -2.0f;
if (indexX >= 2.0f)
directionG = "up";
if (indexX <= -2.0f)
directionG = "down";
if (indexZ >= 2.0f)
directionG = "left";
if (indexZ <= -2.0f)
directionG = "right";
if (directionG == "up")
indexZ += 0.03f;
if (directionG == "down")
indexZ += -0.03f;
if (directionG == "left")
indexX += -0.03f;
if (directionG == "right")
indexX += 0.03f; I don't think I'm doing anything wrong but I get this error: 1>e:...\main.cpp(27) : error C2146: syntax error : missing ';' before identifier 'directionG'
1>e:\...\main.cpp(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\...\main.cpp(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int The other errors have to do with not being able to convert a char to an integer. Any ideas?