How to change mecanim speed on pick up?

So, using the Unity mecanim, I want to change the walk speed of the mecanim upon object pick up.
I already made a script called “score” which destroys the objects when player touches it, but I am not sure how to change the speed value of the mecanim.

Here is the code:


function OnCollisionEnter(col: Collision)
{

if(col.collider.name == “PowerUp”)
{

// BotControl.animSpeed = 3;
//powerUpper.GetComponent(BotControlScript).animSpeed = 3f;

audio.PlayOneShot(speedSound);

Destroy(col.gameObject);

print("Powered up");

}


The green (or red here the forums) slashes were my attempts to make it work, but it didn’t work.

check out the docs for “Animation”.

var anim : Animation; //in hierarchy drag here the object with the Animation component with its animation clips
private var walkSpeed : float = 0.5; //animationspeed

for (var state : AnimationState in anim) {
    	state.speed = walkSpeed;
}