Hi everybody,
I followed what was written by “simple” in this post: Dynamically Changing the Character Motor Script - Unity Answers
particularly, here is my code:
function Start () {
gameObject.GetComponent(CharacterMotor).movement.maxForwardSpeed = 10.0f;
}
but I get the following error by unity: UnityException: You are not allowed to call this function when declaring a variable.
Move it to the line after without a variable declaration.
If you are using C# don’t use this function in the constructor or field initializers, Instead move initialization to the Awake or Start function.
UnityEngine.Component.get_gameObject ()
what’s wrong?