Cannot access an animation from script

by StuckInPhD   Last Updated November 09, 2018 01:13 AM - source

I want to change the reload speed of my player when a button is pressed in the pause menu.

I created a button and attached the following script to it (as suggested by the documentation here: ):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PauseUpgrade : MonoBehaviour {

public Animation reloadAnim;
private float startSpeed;
// Use this for initialization
void Start () {
    startSpeed = reloadAnim["Reloading"].speed;

public void upgradeSpeed()
    reloadAnim["Reloading"].speed += 0.5f;

But this does not work. I cannot seem to drag the reload animation into the public variable declared above. Is this the correct way to solve this?


Tags : unity animation

Related Questions

Parameter 'Blend' doesnt exist

Updated February 16, 2018 23:13 PM

Calculate animation weights based on two variables

Updated April 15, 2019 06:13 AM

Bones are rotated wrong direction on play mode

Updated August 27, 2018 17:13 PM