So I’m working on a class project (and we are allowed to seek help) and I have three chests in my level. I have started a C# script for them and I want it to check if the player (who is in FP)has clicked on the chest. If so I want it to play the open animation and I want a random object (sword/bow/potion/coin) to pop out.
I’m starting with the open animation. Here’s what I have so far (not much), but I keep getting an error saying that it is “required to access a non-static member”. I’ve tried the current way & “.CrossFade” and both give me the same error.
Please help…
Code:
void Update ()
{
if (Input.GetMouseButtonDown (0))
{
Animation.Play (“OpenAnime”);
}
}
P.S.
I’m using Unity 5
Edit
I forgot to mention, I was doing this in C#. But all I could find was scripts on how to do it in Java. I tried one and no errors, but no animation either! Here’s the new script:
#pragma strict
public var OpenAnime: AnimationClip;
function Start ()
{
}
function Update ()
{
if (Input.GetMouseButton(0))
{
GetComponent.<Animator>().Play("OpenAnime");
}
}