Problems with animations (Beginner)

Updated on November 13, 2016 in [A] Animation
Share on Facebook0Tweet about this on Twitter0Share on Google+0Share on Reddit0
2 on November 12, 2016

Help me please, i tried making a animation like in the brackeys video, but this error keeps popping up. I made the animation and attached it to the weapon. Help me.

An instance of type ‘UnityEngine.Animation’ is required to acces non static member ‘play’.

I also got the same script as him with everything right.

  • Liked by
Reply
0 on November 13, 2016

Make sure that the object that you’re trying to animate has all the components (check in the inspector) of the one in the video. A script copy could help me understand better.

  • Liked by
Reply
Cancel
0 on November 13, 2016
#pragma strict
var TheDamage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
var Knife : Transform;
function Update ()
{
    if (Input.GetButtonDown(“Fire1”))
    {
        Knife.animation.Play(“Attack”);
        var hit : RaycastHit;
        if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
        {
            Distance = hit.distance;
            if (Distance < MaxDistance)
            {
                hit.transform.SendMessage(“ApplyDamage”, TheDamage, SendMessageOptions.DontRequireReceiver);
            }
        }
    }
}
  • Liked by
Reply
Cancel