How to alter values in a Character Controller?i'm

im attempting to alter the “maxForwardSpeed” variable in the character motor script which comes attached to the FPS controller prefab, but it’s being annoying

i’m trying to make it reduce to 5.0 from the default 10.0

Player.GetComponent(“CharacterMotorMovement”).maxForwardSpeed = 5.0;

but this isn’t able to access it, saying object reference not set to instance of an object. what gives?

Your Player variable is null or doesn’t have a CharacterMotorMovement component.

as far as i know, neither of those are the case since CaracterMotorMovement is a class within the CharacterMotor script

here’s my code

var water = 20;
var fatigue : float = 100;
var n : int= 1;
var Player : GameObject;
Player = GameObject.Find("Capsule");
var panting : boolean = false;

//Player.GetComponent("CharacterMotor");

function Update () {


if(panting)
Player.GetComponent("CharacterMotorMovement").maxForwardSpeed = 5.0;

if (fatigue < 100)
    fatigue = fatigue + (6.0f * Time.deltaTime); 


if(Input.GetKey(KeyCode.LeftShift)  Input.GetKey(KeyCode.W)) 
    fatigue = fatigue - (14.0f * Time.deltaTime); 
   
   
if(fatigue < 50)
panting = true;

}

As far as you know? Have you checked or are you just assuming? CaracterMotorMovement isn’t a component just because it is defined within CharacterMotor. Trivial diagnostics:

function Update() {
    Debug.Log('Player: '+Player);
    Debug.Log('CharacterMotor: '+Player.GetComponent("CharacterMotor"));
    Debug.Log('CharacterMotorMovement: '+Player.GetComponent("CharacterMotorMovement"));
    ...
}

well considering that using CharacterMotor.maxForwardSpeed results in a missing field exception, claiming that “the field CharacterMotor.maxForwardSpeed” was not found

and CharacterMotorMovement.maxForwardSpeed results in an object reference not set to instance of an object error

i don’t know what to assume

I believe there is a method for this toward the end of this thread.

My point was: don’t assume, check; verify. Perform some perfunctory diagnostic tests.

ah, excellent, that thread solved it!
strange, i could have sworn i tried a double dot operator to get to the movement class, oh well. this works, im not complaining