Unity Error

Updated on September 6, 2017 in  [G] Say Hello!
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on September 6, 2017

Assets/Scripts/Indingo_Lava_Burst_Activator_Deactivator.cs(62,16): error CS0120: An object reference is required to access non-static member `UnityEngine.Animator.GetCurrentAnimatorStateInfo(int)’

 

________________________________________________________________________________________

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Indingo_Lava_Burst_Activator_Deactivator : MonoBehaviour
{

private PolygonCollider2D myPolygonCollider2D;

private Animator myAnimator;

private bool lava_burst;

private Rigidbody2D MyRigidbody;

private Indingo_Movement indingoMovement;

private Indingo_Jump_01 indingoJump01;

private Indingo_Jump_02 indingoJump02;

// Use this for initialization
void Start()
{
myPolygonCollider2D = GetComponent<PolygonCollider2D>();
myPolygonCollider2D.enabled = false;
myAnimator = GetComponent<Animator>();
MyRigidbody = GetComponent<Rigidbody2D>();
indingoMovement = GetComponent<Indingo_Movement>();
indingoJump01 = GetComponent<Indingo_Jump_01>();
indingoJump02 = GetComponent<Indingo_Jump_02>();
}

// Update is called once per frame
void FixedUpdate()
{
if (Input.GetKey(KeyCode.G))
{
myAnimator.SetBool(“lava_burst”, true);
myPolygonCollider2D.enabled = true;
indingoMovement.enabled = false;
indingoJump01.enabled = false;
indingoJump02.enabled = false;
}
else
{
myAnimator.SetBool(“lava_burst”, false);
myPolygonCollider2D.enabled = false;
indingoMovement.enabled = true;
indingoJump01.enabled = true;
indingoJump02.enabled = true;
}

if (MyRigidbody.velocity != Vector2.zero)
{

myPolygonCollider2D.enabled = false;
Debug.Log (“Player Is Moving”);

}

if (Animator.GetCurrentAnimatorStateInfo (0).IsTag (“One”))
{
Debug.Log(“Lava_Burst Animation Is Playing”);
}
}
}

  • Liked by
Reply
0 on September 6, 2017

What about changing

if (Animator.GetCurrentAnimatorStateInfo (0).IsTag (“One”)) 

to

if (myAnimator.GetCurrentAnimatorStateInfo (0).IsTag (“One”)) 
  • Liked by
Reply
Cancel