Daemoc Posted June 14, 2019 Share Posted June 14, 2019 I looked around for this information, but had no luck finding it. In the script animation calls, there are 3 values at the end of the string. Through trial and error I think I figured most of it out, although it does not make much sense. The first value seems to be playback speed. The question I have is how does this calculate? I have an animation set to 30 frames a second in the model, but in engine I have to set it to a value of 0.02 to look right? What is the equation here? The second number, I am guessing is the frame count? Shouldn't this be set by the animation though? I have even seen a third value on a few strings, but I have not figured out what this does, or if it is even required. Sorry for the stupid questions, but this does not seem to be documented anywhere. Quote Link to comment Share on other sites More sharing options...
Solution Yue Posted June 14, 2019 Solution Share Posted June 14, 2019 https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_PlayAnimation The first value refers to the name of the animation or its respective number in sequence. The second value is the speed, this doesn't really agree with my modeling program, and I think it's especially due to the keyframes marked in the animation so it's time to look for a calculation that matches the engine. In the third value, is the speed with which you change between animations, a default value is 500, but I use 100 milliseconds, which implies that the transition between animations is smooth. A fourth value, is by default the number zero, this implies that the animation is reproduced in a cycle where when arriving to the last keyframe it returns to the first one, if the value of the number 1 is put to the animation they are reproduced in a single shot, it is not a cycle and it is then when we can resort to the script in Script EndAnimation(), where the number of that sequence is returned when that animation finishes. Quote Link to comment Share on other sites More sharing options...
Daemoc Posted June 14, 2019 Author Share Posted June 14, 2019 Ha, right under my nose it seems. This is where I was looking... https://www.leadwerks.com/learn?page=Tutorials_Editor_Models-and-Animation I guess I just had a disconnect between models/animation and script. It's obvious now, but I did not even think to look there. Thanks for the heads up, this will make my life a lot easier. 1 Quote Link to comment Share on other sites More sharing options...
Rick Posted June 14, 2019 Share Posted June 14, 2019 I still very much wish we could add any number of callbacks on the timing of the animation instead of just getting an end callback. 1 Quote Link to comment Share on other sites More sharing options...
gamecreator Posted June 14, 2019 Share Posted June 14, 2019 Below is a simple example if you want to write your own system. void characterclass::animate() { double lastanimframe = animframe; animframe += timesincelastframe * animationspeedvariable; // While animation frame is over the total length of the animation, reduce it // so we always stay between 0 and the animation length - 1 while(animframe > (double)model->GetAnimationLength(animstate)-1) animframe -= (double)model->GetAnimationLength(animstate)-1; // You can see if animation hit a specific frame to check for a sword hit on an enemy or whatever action you'd like // The below line checks if we're animating an attack and we hit or passed frame 10 if(animsate=="attack" && animframe >=10 && lastanimframe<10) { // Do action here } // When animation ends... if(animframe > (double)model->GetAnimationLength(animstate)-1) { // You can change your animation state to whatever you'd like // For example, if a sword finished swinging, you can switch back to an idle animation } model->SetAnimationFrame(animframe, 0.7, animstate, true); } Quote Link to comment Share on other sites More sharing options...
Rick Posted June 14, 2019 Share Posted June 14, 2019 I just use the old animation lua script Josh had because I built this idea into it and working with callbacks in Lua is just easier. Still wish by default this LE PlayAnimation function gave us that capability, or he added a RegisterAnimationEvent() function to link the timing to a function. Quote Link to comment Share on other sites More sharing options...
Yue Posted June 14, 2019 Share Posted June 14, 2019 What I have is this for my character. https://paste.ofcode.org/eGevSatEFbYMYjnp2tXfbj Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.