Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
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 |
||||
|
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. |
||||
|
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); |
||||
|
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? |
||||
|
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 |
|