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.

Code Snippets / Control your object animation and interpolation automatically (also timer controlled)

Author
Message
Neptune
18
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 19th Nov 2006 18:32
Hi guys,

I needed an animation system for new game but the loop object command is not powerfull enough so i decided to create a function that could automatically controll all the animations of every object in the game. That way I only need 1 command per object!!!

Okay so here we go. Here is the code first of all:



You'll need to copy all the functions and include the setup code at the top.

Instructions:
Once you create an object in your game you'll need to include it in this animation system by first getting a new animID. eg. mynewobjectanim = NewAnimIndex().

Now setup the system for your object using: objectanim(mynewobjectanim).objectid = objectnumber

Thats it! You are ready to use the commands:

The main function is AnimController. You can call this whenever you like in your loop and it will automatically take care of itself.

Usage:
AnimController(animID,startframe,endframe,loops,blend#)

animID : this is the number we assigned earlier (eg. mynewobjectanim)

startframe : the first frame of the animation you want to play

endframe : the last frame of the animation

loops : the number of times you want the animation to loop. The object will automatically stop animating when it has reached the set number of loops. Use 0 to loop infinitely.

blend# : The speed of the interpolation between different animations. Use 0 for no interpolation.

AnimPause(animId)
Pauses a currently playing animation. Use AnimContinue() to starting playing again from where it left off.

AnimReset(animId)
Use this to reset the animation of an object that has stopped because it has finished playing through the loops. (Doesnt apply to objects set to loop infinitely).


I have included an exe file that show this in action. Use the Up key to play one animation and the Down key to play another. It will play at the same speed on any machine running any framerate. Notice how it automatically interpolates between animations.


Thats it. Hope this is usefull. Let me know what you think

Attachments

Login to view attachments
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 19th Nov 2006 20:40
That's very good, I am definatly going to be using this. To bad I dont model. I will try it on some darkmatter models. Thanks
Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 20th Nov 2006 17:17
Neptune
18
Years of Service
User Offline
Joined: 8th Jan 2006
Location: United Kingdom
Posted: 20th Nov 2006 17:23
Glad you like it. I hope it is of some use to everyone. I know its working wonders already for me in my current project. Makes life so much easier. Plus, the standard loop object command was killing my framerate whereas this runs really fast.

Login to post a reply

Server time is: 2024-11-22 23:12:43
Your offset time is: 2024-11-22 23:12:43