Jump to content

[LE3] Lua get animation percent or frame ?


YouGroove
 Share

Recommended Posts

i have a player firing guns.

I want to call a hit() function only when the looping "fire gun" animation reach for example frame "200"

It is possible to know by code when an animation is playing in what frame the animation is ?

Or between what frames ?

Or on percent number where is the animation actually on the actual frame ?

Stop toying and make games

Link to comment
Share on other sites

You'll need to modify the AnimationManager.lua file. If you look at the Draw() method in there you'll see a frame variable that will tell you what you want. Just have to think of an elegant way to inform your character.

 

Look at SetAnimationSequence at line starting 33. Notice how when you call this to play an animation and the animation doesn't exist, it creates an object and adds it to the self.animations table. What you can do here is copy how they are doing end hook, and add a specialFrame & specialFrameHook parameter. Then you'll have to handle it yourself in Draw().

 

This is something I require as well, so I'll try to make a modified AnimationManager sometime tonight with this functionality.

 

I'm not a huge fan of the way he's doing it. He adds animations to the list the first time you try to call them. I prefer to setup the animations first before calling them so I'll be adding some kind of DefineAnimationSequence() function that you should call in the actors Script:Start().

Link to comment
Share on other sites

Thanks Rick.

It's hard to understand , but i can see the variable "frame" in the animation manager.

I can just make it global and just read it or make a function that will return it's value inside animation manager script.

Stop toying and make games

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...