- Home /
How do I control the Max Fall Speed of the First Person Controller?
I'm trying to control the player's falling speed using the shift key. I want the MaxFallSpeed to stay at 0 but when I hit shift, I want the MaxFallSpeed to bump up to 5, And then back to 0 when I let go. Here's my script:
pragma strict
private var charMotor : CharacterMotor;
private var charController : CharacterController;
function Start()
{
charMotor = GetComponent(CharacterMotor);
charController = GetComponent(CharacterController);
}
function Update()
{
if(Input.GetKey("left shift"))
{
GameObject.Find("First Person Controller").GetComponent(CharacterMotor).maxFallSpeed = 5;
}
}
I could be missing the simplest thing but no matter what I try, I can't seem to control the maxFallSpeed variable inside the Character Motor. Any help would do me great!! Thanks!
char$$anonymous$$otor.maxFallSpeed = 5;
You've already done GetComponent.
Use Debug.Log to check whats failing. Perhaps its working but the value is being overridden by the $$anonymous$$otor script? I'm just throwing it out there, I don't use Character$$anonymous$$otor.
Or in the inspector, you can modify the proprieties of your character motor.