unity3d - Translation UnityScript to C# : Array & GetComponent -
i'm working translate unity project in unityscript c#. have translated part of project, i'm confronted problems:
the first problem linked getcomponent
. have file ennemycontroller.cs
lot of functions get/set enemies. before of function, need initialize charactercontroller
.
private charactercontroller charactercontroller; charactercontroller = getcomponent<charactercontroller>();
you can see context here : http://pastebin.com/u09ah4za. if add code above in function it's working not in class... returned me following error:
unityengine.component.getcomponent (string) method used type enemycontroller.charactercontroller field used type
the second problem linked array in c#. more precisely array of array, unityscript this:
var connected : array = array (); static var waypoints : array = array (); var objects : object [] = findobjectsoftype ( autowaypoint ); waypoints = array ( objects );
i have no idea how translate kind of thing, , can see whole file here: http://perche.jeremy.free.fr/sup_scr/autowaypoint.js
and finish, wanted know difference between ienumerator , ienumerable.
seems first error because calling getcomponent<charactercontroller>()
outside of method, try on start() method.
can translate js arrays in simple c# array (like
int []arrayofints = new int[20];
) or use arraylist if not sure of amount of elements array have. now, have determine kind of elements used. , last question answered here: what difference between ienumerator , ienumerable?
Comments
Post a Comment