My Animation Only Play Once? (Noob)
First One Excuse My English And This Is My Email To Contact Me macroarcadeyt@gmail.com
My Animation Only Play One Time I put a script for animate it I put my 3D model in legacy with all animations in the script and in the "animation" (not in the animator) and it supose to make idle animation and then walk in circles but it only make the idle animation and it do it only one time why this? :/ :( Im desesperated pls answer me PD I See a tutorial to make the script and in the tutorial function it perfectly, I use it in two diferent version of unity and it make the same error and I use like 3 or 4 diferent scripts :/
this is the error that appear in the console
MissingMethodException: UnityEngine.Animation.play
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher ()
Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.Create ()
Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args)
Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object[] args)
Boo.Lang.Runtime.RuntimeServices+c__AnonStorey15.<>m__9 ()
Boo.Lang.Runtime.DynamicDispatching.DispatcherCache.Get (Boo.Lang.Runtime.DynamicDispatching.DispatcherKey key, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args)
UnityScript.Lang.UnityRuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args, System.Type scriptBaseType)
IA.Nada () (at Assets/IA/IA.js:78)
IA.Update () (at Assets/IA/IA.js:51)
And this is the script:
//Estado var Estado : int = 0;
//Animaciones
var nada : AnimationClip;
var caminar : AnimationClip;
var correr : AnimationClip;
var atacar : AnimationClip;
var morir : AnimationClip;
//Valores
var pat : float= 0; var patu : boolean= true;
function Start () {
}
function Update () {
if (pat < 0){
patu= false;
estado= 0;
}
if (pat > 10){
patu= true;
estado= 1;
}
if (patu == true){
pat -= 1 *Time.deltaTime;
}
if (patu == false){
pat += 1 *Time.deltaTime;
}
if (Estado == 0){//nada
Nada ();
}
if (Estado == 1){//patrullar
Patrullar ();
}
if (Estado == 2){//perseguir
Perseguir ();
}
if (Estado == 3){//atacar
Atacar ();
}
if (Estado == 4){//morir
Morir ();
}
if (Estado == 5){//esquivar
Esquivar ();
} }
function Nada () {
GetComponent.<Animation>().play (nada.name);
}
function Patrullar () {
transform.Rotate (Vector3 (0,120,0)*Time.deltaTime);
transform.Translate (Vector3 (0,0,1)*Time.deltaTime);
GetComponent.<Animation>().play (caminar.name);
}
function Perseguir () {
GetComponent.<Animation>().play (correr.name);
}
function Atacar () {
GetComponent.<Animation>().play (atacar.name);
}
function Morir () {
GetComponent.<Animation>().play (morir.name); }
function Esquivar () {
GetComponent.<Animation>().play (correr.name);
}
Answer by Statement · Oct 21, 2015 at 05:41 PM
Looks like the problem is that you are calling Animation.play
which doesn't exist. Animation.Play
exists though. Upper and lower case are important.
If you turn on type safe compilation with #pragma strict
you can catch these errors early. Also you had a typo with estado
and Estado
.
See if it works with those fixes.
#pragma strict
//Estado
var Estado : int = 0;
//Animaciones
var nada : AnimationClip;
var caminar : AnimationClip;
var correr : AnimationClip;
var atacar : AnimationClip;
var morir : AnimationClip;
//Valores
var pat : float= 0;
var patu : boolean= true;
function Update()
{
if (pat < 0)
{
patu = false;
Estado = 0;
}
if (pat > 10)
{
patu = true;
Estado = 1;
}
if (patu == true)
{
pat -= 1 * Time.deltaTime;
}
if (patu == false)
{
pat += 1 * Time.deltaTime;
}
if (Estado == 0)
{
Nada();
}
if (Estado == 1)
{
Patrullar();
}
if (Estado == 2)
{
Perseguir();
}
if (Estado == 3)
{
Atacar();
}
if (Estado == 4)
{
Morir();
}
if (Estado == 5)
{
Esquivar();
}
}
function Nada()
{
GetComponent.< Animation > ().Play(nada.name);
}
function Patrullar()
{
transform.Rotate(Vector3(0, 120, 0) * Time.deltaTime);
transform.Translate(Vector3(0, 0, 1) * Time.deltaTime);
GetComponent.< Animation > ().Play(caminar.name);
}
function Perseguir()
{
GetComponent.< Animation > ().Play(correr.name);
}
function Atacar()
{
GetComponent.< Animation > ().Play(atacar.name);
}
function Morir()
{
GetComponent.< Animation > ().Play(morir.name);
}
function Esquivar()
{
GetComponent.< Animation > ().Play(correr.name);
}
Thanks It Function I $$anonymous$$ade A Lot Of Error With De Upper Case Letter In $$anonymous$$y Codes And Animation.Play jeje Thanks @Statement And Thanks @Guidanel :D
Answer by GiyomuGames · Oct 21, 2015 at 09:19 AM
If you click on your animation object in your Project view you should be able to set it to loop from the inspector. Regarding your code, you should learn about "else if" and "switch". It will improve the quality of your code.
Ok He Loop The Animation Thanks For Help $$anonymous$$e With That But Now He Only Use Idle, the script is like don't use the ping-pong method to make it patrol you know why this? this is a screenshot of all the inspector:
Page 1 $$anonymous$$odel: https://gyazo.com/930da271f8de996d538d4a7a3ddf0e36
Page 2 $$anonymous$$odel: https://gyazo.com/0ef40c5aee688b6cc3626fde92f3eac4
Rig: https://gyazo.com/dba68d3d2172b6d7e06d3df1957bb45c
Page 1 Animation: https://gyazo.com/544c17b8c456eda1f198e284a3b92e9c
Page 2 Animation: https://gyazo.com/abf6cbba722c961369eac3b4420c3dd2
Your answer
Follow this Question
Related Questions
Onde encontro a pasta "projet's assets"? 0 Answers
JSON to .anim file 0 Answers
On button down animation plays 1 Answer
Animations Not Working 0 Answers