I'm working to translate a Unity project originally in UnityScript to C#. I already have translated a good part of the project, but I'm confronted with some problems:
The first problem is linked with GetComponent
. I have a file EnnemyController.cs
with a lot of functions for get/set enemies. But before all of this function, I need to initialize the characterController
.
private CharacterController characterController;
characterController = GetComponent<CharacterController>();
You can see the context here : http://pastebin.com/U09aH4ZA. If I add the code above in a function It's working but not in the class... Returned to me the following error:
UnityEngine.Component.GetComponent (string) is a method but is used as a type
EnemyController.characterController is a field but is used as a type
The second problem is linked with array in C#. More precisely with array of array, the UnityScript is something like this:
var connected : Array = Array ();
static var waypoints : Array = Array ();
var objects : Object [] = FindObjectsOfType ( AutoWayPoint );
waypoints = Array ( objects );
I have no idea how to translate this kind of thing, and you can see the whole file here: http://perche.jeremy.free.fr/sup_scr/AutoWayPoint.js
And for finish, I wanted to know the difference between IEnumerator and IEnumerable.