How to modify the speed on CharacterMotor script

Hello. I’m using the FPS walker and it uses the CharacterMotor script to get movement.

My idea is pressing a button, get more speed, but I cant see any change on the variables of the CharacterMotor script.
How can I do?

her is my code:

var mot : CharacterMotorMovement;

function Update()
{

if (Input.GetKey("c"))
mot.maxForwardSpeed=30;

}

bump!

How can i do for change the max speed using CharacterController?

I can’t found nothing in the documentation, sorry.

	private CharacterMotor control;
	
	void Start ()
      {
	
		control = GetComponent<CharacterMotor>();
	}

	// Update is called once per frame
	void Update () 
	{
		control.movement.maxForwardSpeed = 30;
       }

Sorry this is c#… let me attempt javascript

var control : CharacterMotor;

start()
{
  control.GetComponent(CharacterMotor); // Reference the Script were going to modify
}

update()
{

   control.movement.maxForwardSpeed = 30; // The maxForwardSpeed variable is under movement. You can actually see this in the inspector as well. 
}

Don’t trust me on the javascript but I think that is it.

Hello.
thanks but it is the same that i done. The problem is in CharacterMotor script that have privates and the variable that i modified can’t change in this way.

Well thats a simple fix yet again… Use getters and setter methods/functions…

With c# it looks someting like

public int Speed
{
  get{ return speed; }
  set{speed = value;}
}

However since your using javascript I would think it would be more like this.

function setSpeed(int newSpeed)
{
  speed = newSpeed;
}

function getSpeed()
{
 return speed;
}

Ok thanks, I’ll try it tonight