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: https://docs.unity3d.com/ScriptReference/AnimationState-speed.html ):
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?
The above image shows my animation controller for my player. I am trying to change the speed of the "reloading" animation clip.
I am trying to drap the animation clip from my projects folder into the public variable below, but I get a cross sign preventing me from dragging it in as if its the wrong type or something.
Thanks