Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
How to know if playing of an animation has ended?

bdashraful
Registered User
Quote
2018-12-30 00:16:41

Suppose, I want to switch my weapon and suppose that I have two weapon, Thompson and M249, Now my active weapon is Thompson and want to switch to M249, now I have to play the animation for "Thompson unequipped" and animation for "M249 equipped". I have to wait for the animation of Thompson Unequipped finished and then switch the weapon and then play the equipped animation.

How can I be informed when an animation become finished playing?


serge
Registered User
Quote
2019-02-06 10:44:00

In animation editor you check the time frame


xanimalkingx
Registered User
Quote
2019-02-10 19:41:48

wrote:
In animation editor you check the time frame

Yes but this isnt helpful.
What you can do is get the current time via new Date().getTime(); and then add that with the max time of the specific animation from the animation editor, then take the current timeMs from the behavior onAnimate and check if that timeMs equals the difference of the current time and max animation time.


DeltaXGames
Guest
Quote
2019-03-18 21:05:22

It's not possible to read it (or so I believe), I've tried!
The only way I know to do this is with a (simple) hack. If you know how long the animation lasts (you can easily read this in the animation editor), you could start a timer at the start of the animation and then execute your action at the end of the animation .

Here's some example code, here I force the player to wait till the reload animation has played before he can fire his weapon, may not be exactly what you are looking for but I hope it helps you.

var __deltaTime=0;
var __lastTime=0;
var isFirstCount=true;

function getDeltaTime()
{
var now=(new Date()).getTime();

if (isFirstCount) {
__deltaTime=0;
isFirstCount=false;
} else {
__deltaTime=now-__lastTime;
}

__lastTime=now;
}

ccbRegisterOnFrameEvent(getDeltaTime);

//End of Delta Time Code

var animationEnd=1000;//the length oth the animation in milliseconds. You might need to reset this every time the animation starts.
function gameLoop() {
//put your game code here

if (animationEnd<=0) {
//The animation has ended;
} else {
animationEnd-=__deltaTime;
//animationEnd=1000; //If the animation is looping then you might need to uncomment this.
}
}

}
ccbRegisterOnFrameEvent(gameLoop);


JaimeZegpi
Guest
Quote
2019-04-29 06:18:48

var s = ccbGetSceneNodeFromName("cubeMesh1");

var animation = ccbGetSceneNodeProperty(s, "Animation");

print( animation );
For animated scene nodes, Properties like 'Animation', 'Looping', 'FramesPerSecond' 'AnimationBlending', and 'BlendTimeMs' are available.

this Works?


calabrovarijo
Registered User
Quote
2019-06-16 19:37:09

bdashraful wrote:
Suppose, I want to switch my weapon and suppose that I have two weapon, Thompson and M249, Now my active weapon is Thompson and want to switch to M249, now I have to play the animation for "Thompson unequipped" and animation for "M249 equipped". I have to wait for the animation of Thompson Unequipped finished and then switch the weapon and then play the equipped animation.

How can I be informed when an animation become finished playing?

In animation editor you check the time frame


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Intern?tional" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact