How do I play an animation on an avatar?


#1

Kev asked me to make him a playing guitar animation which I think I did

I don’t know how to play it to test if it works, they use to go in attachments.
I see a json thing beside avatar settings but I don’t know how to use that
Anyone know how to run it?

answer
MyAvatar.overrideAnimation(“https://dl.dropboxusercontent.com/u/10483952/kevguitaranimation.fbx”, 30, true, 1, 100);

and

MyAvatar.restoreAnimation()
[/quote]

:slight_smile: Thanks @Menithal @hyperlogic


#2

They used to have a UI/UML component for it, but i do not know where that went

Scriptingwise however:

To play an animation:

MyAvatar.startAnimation
MyAvatar.overrideAnimation(url, fps, boolean loop, boolean hold, startFrame, endFrame) in the script console.

  • hold true stops the animation and the end and it stays in the final frame.
  • loop true loops the animation

You can set these using the console without making a script

Then there is MyAvatar.stopAnimation() MyAvatar.restoreAnimation()

There also are the role animations but i wont get into those.
So someone probably could create a ui element to set those :slight_smile:


#3

MyAvatar.startAnimation (https://dl.dropboxusercontent.com/u/10483952/kevguitaranimation.fbx, 30, true, false, 1, 100)
gives me an error
Sod it am not wasting a day of my holiday doin’ a favor
am not a scripter and shall never be lol

thanks anyways


#4

it gives you an error because the url is not a string, try

MyAvatar.startAnimation(“https://dl.dropboxusercontent.com/u/10483952/kevguitaranimation.fbx”, 30, true, false, 1, 100)

instead

edit: its overrideAnimation not startAnimation


#5

TypeError: Result of expression ‘MyAvatar.startAnimation’ [undefined] is not a function

@.@

because a box which says animation url is 2 much to ask lol


#6

I’m not sure what happened to the boxes, but the animation system is designed to work the avatar rig and roles most of the time now.
The rig has states like idle and fly, and the idea is you can override those, so you could set the guitar playing animation to always happen when idle instead of the standing.
You should be able to do it as a one-off event as well as Menithal describes but I’ve not tried that recently.
The benefit of a rig driven approach is you can stop the avatar doing things like flying and doing the animation at the same time.
Got some other things to look into, but I can try and cook something up with the file if you want later.


#7

@KevinMThomas no I won’t make you a guitar animation Just do the show in second life :smiley:


#8

I only remember play animation, and searched with that and got examples, but since I was typing everything with my phone I didnt check that they were assignment client scripts…

So instead, is seems like it is MyAvatar.overrideAnimation instead which isnt simply, but is logical, because its overriding the role animations. Id however prefer a simple playAnimation is much more direct, which is the same with Assignment Client scriptable avatar. I just wish they APIs were consistant. overrideAnimation needs to same playAnimation features for ignoring some bones.

Now that I am finally home I can finally test what I wrote:

@Judas my bad, Its actually. I tested them this time. I swear.

MyAvatar.overrideAnimation(“https://dl.dropboxusercontent.com/u/10483952/kevguitaranimation.fbx”, 30, true, false, 1, 100)

and

MyAvatar.restoreAnimation()

The reason for override instead of playAnimation is two fold: There is no blending of animations like in SL. instead thats what the Role animations are for: and the frames are there so that you can define multiple animations into a single fbx file and just use frames to define what part of the animation to play back and at what speed.


#9

WOOHOO!!! Oh yea!!!


#10

well I get pre post shenanigans and its not playing the animation
but its sorta right

thanks for the fix @Menithal

Judas returns to his never going near anything avatar related again policy .


#11

Hey, It’s great to see folks experiment with avatar animations! Two quick points.

  1. The call should actually be MyAvatar.overrideAnimation(“https://dl.dropboxusercontent.com/u/10483952/kevguitaranimation.fbx”, 30, true, 1, 100); There is only one boolean, which is the loopFlag. It is documented in more detail here.
  2. Our animation system doesn’t currently support sparsely distributed keyframes. To get the best results you need to have a keyframe on every 1/30th of a second. This particular guitar playing animation does not. So, Although it plays back, it’s doesn’t look quite right. I could be wrong, but I think there are blender scripts available that will bake out the keyframes.

Hope this helps,


#12

thanks @hyperlogic its playin gittar now lol
Still folds up but i think thats my obsolete rig pre post fixes it and it ends up in a odd location for me which is either related to my rig or my animation


#13

I woulda spent longer on it but it took me an entire day to get to a point where I could play it in world to check if it worked at all
Not wasting my days off limping through code