Influencing Third Person Controller's walk speed from another method?

Hey everyone,

So I’m working on a little worm game where the user competes with another worm for apples. You can see the rough version of it here: http://www.pages.drexel.edu/~jhp33/WebPlayer.html

Currently the worm uses the default third person character movement and controller from Unity’s premade scripts.

I’m not at a computer now, but I think the variable that defined walk speed was something like “maxWalkSpeed.” I could be wrong but it’s something along those lines.

Anyway, I wanted to make it so that when a golden apple is eaten, the user gets a five second speed boost.

My question is: how do I influence maxWalkSpeed from outside the third person controller? I tried using a gameObject.ThirdPersonController.maxWalkSpeed+=3 type approach (something like that, not at my workstation so I can’t see the exact syntax and names) but it didn’t seem to work. Would I have to make that change within the character controller itself? A code example would help me get a grasp on what I’m missing.

I assume the five second part could be accomplished by a Time.deltaTime if statement, but I’d have to play around with it a bit more with a working speed boost to find out.

Thanks Comm-Unity!
J-Patt

You’d want to access the walk speed by doing

if (go)
gameObject.GetComponent(CharacterMotor).movement.maxForwardSpeed = appleSpeed; 

else
gameObject.GetComponent(CharacterMotor).movement.maxForwardSpeed = defaultSpeed;

Where appleSpeed and defaultSpeed are variables. For the five-second part, you’d want to do a function:

function OnGetGoldenApple ()
{
go = true;
yield WaitForSeconds (5);
go = false;
}