Converting variable from javascript to C#

Hi,

I just started learning Unity and teaching myself C#. I’m following an online tutorial that uses JS, and I’m trying to convert the code to C#.

I’ve used the m2h.nl jsToC# converter site, and this is the error I’m getting:

Javascript:

private var instanBoosters;

C#:

private FIXME_VAR_TYPE instanBoosters;

I’ve tried assigning the var as a string or float, but I get the errors.

Any idea what can replace the variable type on that line?
Thanks.

You have to know what the Type of object instanBoosters is, which is the issue with the dynamic nature of javascript. In javascript you don’t have to define the type unless there is no value in it. In C# you can’t just randomly switch the type. For example, you can’t make an integer a float unless you cast. If it’s a string you would do:

String someString; //define type, then name of variable.

Do you know what type of object instanBoosters is?

OK, so it depends on what you are instantiating the object as. Usually you would define it as transform. So it would be:

Transform instanBoosters;

//when you instantiate do this:

instanBoosters= Instantiate(object,position,rotation) as Transform;