Reputation: 2697
Based on this Unity Animator API, there's a public function named IsInTransition. but why i cannot use it?
When i try to code in MonoDevelop, the Autocompletion wont work and also build was Error :
Assets/Scripts/CatAnimator.cs(32,18): error CS1061:
Type `Animator' does not contain a definition for `isInTransition'
and no extension method `isInTransition'
of type `Animator' could be found.
Are you missing an assembly reference?
any idea ?
The Complete Code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Animator : MonoBehaviour {
Animator myAnimator;
public float speed = 10.0f;
public float jumpSpeed = 8.0f;
public float gravity = 20.0f;
private Vector3 moveDirection = Vector3.zero;
CharacterController controller;
float currSpeed, Param1;
bool Param2, Param3;
// Use this for initialization
void Start () {
controller = GetComponent<CharacterController> ();
myAnimator = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
Param1 = 0;
Param2 = false;
Param3 = false;
if (controller.isGrounded) {
//==
}
if (myAnimator.IsInTransition (0)) { //ERROR HERE...
}
}//==update
}//==class
Upvotes: 1
Views: 369
Reputation: 1815
The problem here was the fact that you are making a class named Animator
. However there is an animator class already provided by Unity
. When you declare an object of type Animator
(Animator myAnimator;
), the compiler thinks of your class instead of the class provided by Unity
. And in your class there is no IsInTransition()
method to use.
To fix this simply rename your class to MyAnimator
for example.
Upvotes: 2