Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Retrieving current animation index? Tier 1

Author
Message
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 25th May 2017 04:01
Hello! This is my first time posting here.

Is there a command in Tier 1 to retrieve the index (and/or name) of an object's currently playing animation? Or is this something I'll just have to keep track of manually? Apologies if I've missed something obvious. A forum search didn't reveal anything and I didn't see any commands in the documentation that do this.

Thanks!

-h
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 26th May 2017 14:37
Welcome to the forums.

I think the ObjectIsAnimating command is what you're after. This will return a 1 if the object is currently playing an animation.
Hover Car Race Challenge! - available now on Google Play
Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 26th May 2017 17:01
Hi 29 games, thanks for the reply! I'm actually wanting to get the index (or name) of the animation that is currently playing. Something like:

if GetObjectPlayingAnimation(obj) = 2 (or "AnimationName")
do stuff
end if

I'm working on some code to link triggers to animation times, but I only want a trigger to fire if the animation it is linked to is playing. I'm guessing I'll just need to keep track of this manually (or re-think my logic a bit). I was just wondering if there was some built in way that I was missing somehow.

-h
AjiMundi
8
Years of Service
User Offline
Joined: 28th Sep 2015
Location:
Posted: 27th May 2017 06:00
If you mean 2D sprite animation, there is this command: https://www.appgamekit.com/documentation/Reference/Sprite/GetSpriteCurrentFrame.htm
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 27th May 2017 17:54
Hi AjiMundi, sorry I should have specified that I'm referring to 3D object animations. 3D objects can contain multiple animations that are stored by name in a list. When you call PlayObjectAnimation, you have to specify the name of the animation that you want to play. But it seems there is no way to ask AppGameKit which animation an object is currently playing. I can, as 29 games suggested, use GetObjectIsAnimating to find out if the object is playing an animation, but it doesn't tell me which animation is playing.

It's not a problem anymore, though. I'm redoing the way I handle animations to account for this.

Thanks!

-h
AjiMundi
8
Years of Service
User Offline
Joined: 28th Sep 2015
Location:
Posted: 28th May 2017 01:52
Ah, I see. This seems to be an important feature. Perhaps you should mention it in the feature request thread.
MikeHart
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 28th May 2017 14:57
Ehm. When you start the animation of your object in the first place, don't you know it then already?
Running Windows 7 Home, 64 bit, 8 GB ram, Athlon II X2 255, ATI Radeon HD 4200. Using AGK2 Tier 1.
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 28th May 2017 16:41
Yes, this was just a case of wanting to keep my code as simple as possible. My animation event code didn't necessarily know which animation an object was playing (that was set elsewhere), but needed to change behavior based on it. I wanted to ask the object directly which animation was playing instead of keeping track of it in a global. No big deal

-h
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 29th May 2017 08:51 Edited at: 29th May 2017 08:55
I think, you have to use an array, and don't use names, if possible.



You could say: if say play Animation with Index 1 from the array you can look at StartFrame and EndFrame or the name

A lot of the objects I am using, have no specific Animation-names. Only one animation and I have to seperate them. On the objects I am loading GetObjectNumAnimations() is everytime 1.

So the names are only for later maybe, but are not in my models. And I miss the command: SetAnimationName.

If you want to know, which animation your object is playing, you would need to save the String for the object. You could do it maybe with an array of strings. And the objectID is the index of your array. But sometimes objectIDs could be very high, so your array could also can became big.

hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 29th May 2017 19:52
Hi Xaby, thanks for the suggestions. Do you know if the animation names are only loaded with certain file formats? I use FBX and the animations are always stored in a list by name. I suppose I could chain them all together into one big animation in blender and then just go by the animation time, but I like the idea of them being stored separately.

Anyway, I did end up using a couple of type definitions. Here is a simplified version of my animation event code if anyone's interested.



and to use it:



-h
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 3rd Jun 2017 00:40
AGK does not store animation names. It uses frames.

One option is to store the animation as its own object. (ie walking, running, attacking)

Two is like you said - use blender. This is the option I have used. Although, I am not against storing each animation as an object. I just have never tested if there is a file size difference.

My animation events are very similar to yours.

hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 3rd Jun 2017 03:40
Hi Golelorn,

Quote: "AGK does not store animation names. It uses frames."


Sorry if I'm misunderstanding you, but the FBX models I am using certainly do have their animations stored in a list by name, accessible with the GetObjectAnimationName command. For instance, this code will output a list of all of my object's animations by name.



output:

1: idle
2: walk
3: run
etc

When I call PlayObjectAnimation, I have to pass in the name of the animation as opposed to a blank string like you've shown. And telling it to play from frame 0 to the end will only play the entirety of that particular animation.

-h
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 4th Jun 2017 14:08
I apologize. I thought you were asking if AppGameKit will return the animationname that its currently playing. That's what I meant when I said AppGameKit does not store it. If I am wrong, then that is fantastic news.

I believe you have to grab the frame on your own, and deduce where you are at. Which I do with the following commands:

GetObjectAnimationDuration
GetObjectAnimationTime


With those commands you should be able to figure out where you're at. I have to get the duration of each animation, and then retrieve the time.
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 4th Jun 2017 15:52 Edited at: 4th Jun 2017 16:01
No problem! That is indeed what I was asking. There is no way in AppGameKit Tier 1 to find out directly which animation an object is playing.

With my objects it's not possible to deduce the animation based on the current frame. GetObjectAnimationTime will only return a number between 0 and the duration of the given animation. I suppose I could use GetObjectAnimationDuration to differentiate between the animations, but that would require every animation to be a unique duration. That's why I ended up using a type definition (AnimatedObject) and wrapper function (PlayAnimatedObject) to keep track of an object's currently playing animation manually.

-h
hoyoyo80
7
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 4th Jun 2017 16:01
i suggest 3d animation should have more command to control the animation. Maybe we can load model with animation and then extract animation from the model like walk,run,idle. and then we can check from the extracted animation, e.g if currentanimation=walk then...something like this..
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 12th Jun 2017 13:45
I am also looking for a more advanced Animation-System. Also Blending between Animations.

For example Moving-Hands (Bones 1..10) from Animation "Talk" and Moving-Feed (Bones 15..20) or so from Animation "Running"
Like layered animations.

I am also interessted in an Animation Chain. Maybe you know, your character has to Move to XYZ position with Looping the Walk-Cycle and than have to "sit_down", and than he/she has to "Talk". So for every object it would be nice to have a time-line or so. Or you could "preCompile" Animations to a new Animation "Walk-To-SitDown-Talk".
But that would cause other problems like much space if you have to save the walk-cycle very often to get from XYZ to Destination-XYZ.

The Syntax could be: MoveObjectAnimation(ObjID, "Walk;Sit_Down;Talk","30,0,1",25,X, Y, Z)
And this would mean, that the Object with ObjID moves from its position to XYZ with 30 Cycles of "Walk" (Looping 30 times), than 1 Cycle "Sit_Down" and Looping forever "Talk". Speed is 25 Frames per Second. I don't know, If there is a need for Tweentime between the Animations.

The idea is, that the Animations-Handling could work completly in the background. With Not-Asking every frame, if the animation is done, etc.

hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 12th Jun 2017 17:48 Edited at: 12th Jun 2017 18:01
Yeah, I'm finding AGK's 3D animation playback commands to be (currently) quite limited. Animation blending is pretty much a must have these days and a timed tween from one animation to another is not really enough, in my opinion. I thought it would be for my purposes, but it isn't. I want more control over the blending.

However, it's totally possible to roll your own using AGK's bone position and rotation/quaternion commands, so I've started working on a system to handle per-bone animation blends. I can probably share it here when I get it somewhat finished.

-h

Login to post a reply

Server time is: 2024-04-25 07:13:06
Your offset time is: 2024-04-25 07:13:06