- Home /
Ambigous Reference Animation
Hello everyone,
I've learned some valuable lessons today. Chief among them: If you're going to build to Android, do so from the very beginning of your project, lest you end up like me and have over 110 shiny brand new compiler errors when you go to make your build :)
So, I'm happy to report that through the grace of God, and doing a lot of Googling I've been able to whittle these errors down to 5. These last few have me stumped, even with searching and finding some answers. I have the following: (all five errors are the same, in different places, so just posting one)
Assets/Standard Assets (Mobile)/Scripts/AI.js(26,20): // (also line 41 - added by OP) BCE0004: Ambiguous reference 'Play': UnityEngine.Animation.Play(UnityEngine.AnimationPlayMode), UnityEngine.Animation.Play(UnityEngine.PlayMode).
I've seen the same error in search results, but never pertaining to animations. Am hoping someone can point out what I'm doing wrong. Thanks, and God bless.
var target : Transform;
var moveSpeed = 1;
var rotationSpeed = 2;
var myTransform : Transform;
var minDistance = 30;
var stopDistance = 1;
function Awake()
{
myTransform = transform;
}
function Start()
{
target = GameObject.FindWithTag("Player").transform;
}
function Update () {
if(Vector3.Distance(myTransform.position, target.position) < minDistance)
{
animation.Play(1);
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
Halt();
}
}
function Halt()
{
if(Vector3.Distance(myTransform.position, target.position) < stopDistance)
moveSpeed = 0;
else{
moveSpeed = 1;
animation.Play(2);
}
}
Answer by GameVortex · Jan 27, 2014 at 09:10 AM
As it says, it is an ambiguous reference on line 26 and 41 between the functions .Play(UnityEngine.AnimationPlayMode) and .Play(UnityEngine.PlayMode). Those two functions require different types of Enums. You are using an int to specify the enum, but the compiler does not know which enum you mean. Therefore it does not know which function to use.
So either cast the int to the correct enum or specify the enum directly:
Casting:
animation.Play((PlayMode)1);
Specify:
animation.Play(PlayMode.StopAll);
Your answer
![](https://koobas.hobune.stream/wayback/20220613131541im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animation problems 1 Answer
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers