Jump to content

Where you are in the animation


Rick
 Share

Recommended Posts

With the new animation functions on the entity, is there any way to tell where you are within the animation? There is a SetAnimationFrame() but I don't see a GetAnimationFrame(). I need this to tell when we've hit or just went passed special frames in an animation. I use this all the time and it's the only thing that keeps me on the old AnimationManager.lua so it would be handy if we could tell what "frame" we are currently on.

Link to comment
Share on other sites

SetAnimationFrame() is the original method and since the user actually controlled the frame number being used in that method, there was no reason to have a GetAnimationFrame(). But now with PlayAnimation() being the end result of the animation manager written in c++, there is no current method to retrieve that value. So if you need to know, you will need to still use the old method and track the frame yourself. If its not a post in the suggestion box yet for this to be added, it should be. 

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Just like the animation manager script, there can be multiple animations running at once that are being blended between.  There isn't really a single animation time value that can be retrieved.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Right, I assume each entity has a list of animations playing (because of blending mostly) but we know the sequence name of each. Given this we should be able to query the list for that name to get it's current frame. All of this is about attaching events/callbacks to "frames" within the animation so that one can do things at certain points within the animation. Something that is very handy for a lot of reason. Will it always be perfectly on that frame? No, but it can be close enough where to humans it looks to be perfectly on that "frame". Examples of usage is real footsteps when the feet are hitting the ground, casting spells requires doing things at certain points in the frame, causing melee damage in some turn based games, etc. This is a pretty common thing to do. I'm able to do this with the AnimationManager script because I've added a special frame callback system. It would just be nice to not have this script requirement for playing animations anymore and use built in functions for this.

Link to comment
Share on other sites

We could do something like this:

float GetAnimationTime(int sequence=0)

Where 0 is the last sequence you played, 1 would be the previous one (if it is still active, otherwise 0 is returned), etc.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

8 hours ago, Rick said:

we know the sequence name of each. Given this we should be able to query the list for that name to get it's current frame.

This won't work because you can blend two of the same animations.  But Josh's idea seems pretty good.

Of course, manually incrementing the frames and playing sounds isn't too difficult.

// Pseudocode
newframe = Time::GetSpeed()+oldframe;
if(footstepsoundframe>oldframe && footstepsoundframe<=newframe) playsound()

 

Link to comment
Share on other sites

1 hour ago, gamecreator said:

This won't work because you can blend two of the same animations.

What is the situation this happens? I was confused on how this would happen.

 

1 hour ago, gamecreator said:

Of course, manually incrementing the frames and playing sounds isn't too difficult.

My example was a specific example. I could do a lot manually if I wanted but it's nice when an API helps you. At it's core it's about raising events at specific times in animations so you can do whatever you want to do. This is a very common thing that the other engines have and it would be nice to have it built in. He has end hook but that's not good enough. I use the old AnimationManager.lua which I'm manipulated to allow this but it's an extra dependency which would be nice to not have.

Link to comment
Share on other sites

10 hours ago, Josh said:

We could do something like this:


float GetAnimationTime(int sequence=0)

Where 0 is the last sequence you played, 1 would be the previous one (if it is still active, otherwise 0 is returned), etc.

How about instead having PlayAnimation return a handle/id, which you could later use to query the status?

  • Upvote 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...