Tundra Script

18 views
Skip to first unread message

Vaibhav Vaidya

unread,
Mar 27, 2012, 5:47:30 AM3/27/12
to real...@googlegroups.com
Hii all,

var entityNameToFind = "UrbanFemale.";

function ShowAnimation()
{
    var objectToAnimate = scene.GetEntityByName(entityNameToFind);
    console.LogInfo("Hey great, I found " + entityNameToFind +" Starting animation");
var availableAnims = objectToAnimate.animationcontroller.GetAvailableAnimations();
console.LogInfo(availableAnims);
}
else
{
       console.LogWarning("Entity " + entityNameToFind + " was not found or animation controller component is not there! Trying again in 1 second.");
        frame.DelayedExecute(1.0).Triggered.connect(StartAnimation);
    }
}

// Only run on client. One time animation enabling.
if (!server.IsRunning() && !framework.IsHeadless())
{
    StartAnimation();
}




Vaibhav Vaidya

unread,
Mar 27, 2012, 5:59:31 AM3/27/12
to real...@googlegroups.com
Hii all,

I have written the following script. I checked "Run on load" to true. When I launch the client see the message:
Hey great, I found UrbanFemale. but do not see the available animation.

 But when i go to view -> scene -> UrbanFemale. -> AnimationController -> functions -> GetAvailableAnimations()
It shows me the animation "Walk".

var entityNameToFind = "UrbanFemale.";

function ShowAnimation()
{
    var objectToAnimate = scene.GetEntityByName(entityNameToFind);
    
    console.LogInfo("Hey great, I found " + entityNameToFind );
    
    var availableAnims = objectToAnimate.animationcontroller.GetAvailableAnimations();
    console.LogInfo(availableAnims);
}

if (!server.IsRunning() && !framework.IsHeadless())
{
    StartAnimation();
}


Also, when i run the script view -> scene -> UrbanFemale. -> Script -> Run()
This runs the script and shows the message:

Hey great, I found UrbanFemale.
Walk

Am I missing anything?? 

~Vaibhav

Vaibhav Vaidya

unread,
Mar 27, 2012, 6:00:35 AM3/27/12
to real...@googlegroups.com
Please ignore the previous part..

Ali Kämäräinen

unread,
Mar 27, 2012, 7:32:54 AM3/27/12
to real...@googlegroups.com
GetAvailableAnimations() returns a list so you need to print each element:

var availableAnims = objectToAnimate.animationcontroller.GetAvailableAnimations();
for(var i = 0; i <  availableAnims.length; ++i)  
    console:LogInfo(availableAnims [i]);

Grey skies,
Ali Kämäräinen

Vaibhav Vaidya

unread,
Mar 27, 2012, 7:41:39 AM3/27/12
to real...@googlegroups.com
@Ali :

I tried this also but I see the same results.

Ali Kämäräinen

unread,
Mar 27, 2012, 9:28:35 AM3/27/12
to real...@googlegroups.com
I see that your script is calling  StartAnimation(). However, I see no such function in the text you pasted, but only  ShowAnimation(). Are you calling non-exising function by accident?

Jonne Nauha

unread,
Mar 27, 2012, 9:29:05 AM3/27/12
to real...@googlegroups.com
The reason why you get a empty list with "Run On Load" is probably because the skeleton asset has not been inspected yet for the animation names. Also i think you cannot start them if that is the case. This is why later when y ou run the script it responds with the proper anim names.

Seems that there is no proper way to ask ent.animationctonroller.IsReady() or IsDetected() etc. So you can just assume to try again in 1 second if the animation name list is empty like so:

if (availableAnims.length <=  0)
  frame.DelayedExecute(1.0).... etc....

Best regards,
Jonne Nauha
Adminotech developer
Reply all
Reply to author
Forward
0 new messages