Hello, super noob here any advice would be most grateful as I dont really know what im doing very well. Anyway my problem is, I am trying to make a simple script to switch weapons. Now in this script when we switch weapons it switches to a diffrent default animation. We are using 2d side scrolling method, however our artist has made sprite sheet idle animations for every weapon and is insistent on using them. hit key, switches weapon, and goes to default idle for that weapon.
Part of me thinks im trying to go about this all wrong, any advice would be helpful.
Here is a basic code I cannot get to work. and my compiler errors.
using UnityEngine;
using System.Collections;
public class sweapon : MonoBehaviour {
Animator anim;
void Start()
{ anim = GetComponent<Animator>();
}
void Update ()
{
if(Input.GetButtonUp("1"))
{
Animation.Play("_zak-idle-wth-axe.anim");
Animation["_zak-idle-wth-axe.anim"].time = 1.0; }
}
}
This seems so simple to play an animation what is my problem?
Compile errors:
-Assets/sweapon.cs(25,35): error CS0120: An object reference is required to access non-static member `UnityEngine.Animation.Play()’
-Assets/sweapon.cs(26,25): error CS0119: Expression denotes a type', where a
variable’, value' or
method group’ was expected
Please help im pulling my hair out here trying to understand scripting from no background of programming whatsoever.