fox-handler
fox-handler

Reputation: 131

Unity and variables

I started looking at the tutorials for Unity, but there is one thing that I do not understand. I changed the variable myInt in function Start to myInt1, however I get an error Unknown Identifier: 'myInt1'. Am I supposed to declare the variable first? Does #pragma strict have anything to do with it?

#pragma strict

var myInt : int = 5;


function Start (){ 
myInt = MultiplyByTwo(myInt);     
Debug.Log(myInt);                  
}



function MultiplyByTwo (number : int) : int      
{
var ret : int;
ret = number * 2;
return ret;                                

Upvotes: 0

Views: 125

Answers (2)

Mayank Gupta
Mayank Gupta

Reputation: 1

Yes, you need to declare the variable first.

Upvotes: 0

Bigwater
Bigwater

Reputation: 223

In the Update function myInt1 is trying to look for a variable that does not exist, thus you must make both the variable at the top myInt1 aswell.

Also learn C# it is very similar and much more efficient!

Upvotes: 3

Related Questions