- Home /
Question by
$$anonymous$$ · Sep 28, 2013 at 01:26 PM ·
animationstate
Assigning AnimationState
I have a script in which I am trying to make it so as long as the hold down duck the animation pauses at them in duck. When they let go the animation continues and they get back up. To do this I am changing the AnimationState speed to 0, I have a public AnimationState called duckAnim. The problem is I can't assign it as it doesn't show in the inspector. Any way to fix this or get around it?
Here's the code:
using UnityEngine;
using System.Collections;
public class disableDuck : MonoBehaviour {
public AnimationState duckAnim;
private bool animIsPaused = false;
void Update () {
if (Input.GetButtonUp("Duck")){
animIsPaused = false;
duckAnim.speed = 1;
}
}
void duckDisable()
{
PlayerPrefs.SetInt("Ducking", 0);
}
void animPause()
{
if (Input.GetButton("Duck")){
duckAnim.speed = 0;
animIsPaused = true;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Help playing the right animation 1 Answer
Mechanim state triggers twice 1 Answer
Can the animation editor create local rotational data? 3 Answers
Is it possible to make empty, passing state in mecanim? 3 Answers
Adding animation clips via script 2 Answers