Search Unity

CS0119 C# is a method, which is not valid in the given context plz help me

Discussion in 'Animation' started by thomascook0404, Feb 20, 2017.

  1. thomascook0404

    thomascook0404

    Joined:
    Feb 20, 2017
    Posts:
    1
    i dont know why its not working it supposible works for otehr people
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class animationplaygunfire : MonoBehaviour {
    5.  
    6.     // Use this for initialization
    7.     void Start () {
    8.  
    9.     }
    10.     // Update is called once per frame
    11.     void Update()
    12.     {
    13.         if (Input.GetKeyDown("e"))
    14.         {
    15.             GetComponent<ak47fireing>.play(true);
    16.         }
    17.     }
    18. }
    19.  
    20.  
    ak47fireing is an animation
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    I assume you are using an animator, and "ak47fireing" is a state in your animator.

    In which case it should be:
    Code (csharp):
    1. GetComponent<Animator>().Play("ak47fireing");