Hello,
I’ve written the following script:
using UnityEngine;
using System.Collections;
public class revolverMoveAnimScript : MonoBehaviour {
public Animation anim;
void Update () {
if (Input.GetKeyDown(KeyCode.W) && anim.isPlaying == false)
{
anim.Play();
}
}
void Start()
{
gameObject.GetComponent<Animator>().Stop();
}
}
Now if I want to assign my animation to the variable in the inspector, i click that little circle-like button-thingy in the inspector right next to the TextBar saying “None (Animation)”, goto “assets”, doubleclick my animation and - nothing happens. My variable is still unassigned.
Why does the inspector troll me?
Are you trying to add an Animation Clip?
‘Animation’ is a component is it not?
That box wants you to drag in the gameObject with the Animation Component you wish to interact with. It does not accept Clips, which go in to the Animator component itself I do believe.
I have the same problem, except I’m trying to assign prefab by drag’n’dropping it into
public GameObject whatever;
neither drag’n’drop nor assignment from the list under the circle button doesn’t work.
only on that one specific script, everywhere else it works normally.
@DasHouse
Create a class that has a public Animation member.
Create an object in the hierarchy view.
Press: Add Component.
Choose Scripts-> the script for your new class
Drag the object into your assets folder so that you have a prefab of it. Delete it from your scene.
Drag the prefab onto the “anim” member in the inspector.