hello
In javaScript you write
var controller : CharacterController = GetComponent(CharacterController);
controller.Move(moveDirection * Time.deltaTime);
What shall I do using C# ?
hello
In javaScript you write
var controller : CharacterController = GetComponent(CharacterController);
controller.Move(moveDirection * Time.deltaTime);
What shall I do using C# ?
CharacterController controller = GetComponent<CharacterController>();
controller.Move(moveDirection * Time.deltaTime);
There are other ways of calling GetComponent but I prefer the generic method, unless this is for the IPhone.
thanks
It is what I did but it does not work
I get the error message : a variable is expected…
I’m not familiar with that error. Are you sure you’re not writing C# code in a Javascript behaviour? In order to write C#, you have to create a C# behaviour. You can’t just edit a Javascript behaviour because it will still expect to find Javascript there.
well I have created a Sharp script so I suppose to be in C# also I wrote some “struct” no problem
I tried also
CharacterController controller = (CharacterController) GetComponent(typeof(CharacterController));
No error message , but when I add
controller.Move();
I get the message
Expression denote a type where a variable, value or method group was expected
First time for me to use C# with Unity3d but I suppose that all Unity3d / C# users know the answer
At least one to support , please
Can you post the whole script?