Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
animation timings

Robo
Guest
Quote
2021-06-16 14:55:30

I want to adjust the player animation speed according to player movement speed yet this doesnt not work smoothly in CC as changing animation speed using "FramesPerSecond" resets the current animation each time.

To fix the above, I want to calculate accurate time of each full animation like walk etc...comes to 1076 ms at 300 FPS, but when I recalculate the time to complete each animation based of new frames per second amount, it no longer matches a complete animation but is over the place...

My maths seems fine to me and works perfectly when at standard 300 FPS. Anything outside this dosnt work....I cant see why...any ideas ???

the on frame behavior code is below:


// animation speed
if (this.Time > this.animEnd && this.anim == "moving") {
var animFrames = 300 * this.hillSpeed;
ccbSetSceneNodeProperty(this.Player, "FramesPerSecond", animFrames);
var animTime = 323000 / animFrames; // ie 323 animation frames @ 300 FPS = 1076 ms
this.animEnd = this.Time + animTime + 16;
// 16 ms is each on frame delay in the behavior.
}


VP
Guest
Quote
2021-06-18 09:40:45

In theory, the maths looks correct but in practice it sounds like an issue maybe caused by Frame skipping. (Not every frame gets drawn drawn).

I may be wrong but to draw a 300 frames per second animation, I suspect that coppercube is not actually rendering all 300 rames. The higher the animation FPS, the more frame skipping will occur.

Using time as a marker for animation frames is different to using FPS as a counter for time - this can become problematic as frame-rate is variable whilst time is a relative constant.

Syncing animation to time will depend on the refresh rate of the screen, the frame-rate of the game and the FPS of the animation.

For example, if your game is running at 60 Frames per second frame-rate, to draw 600 frames per second animation, it will have to skip certain frames - just like a human eye does - because it doesn't have enough time to draw all the frames in the given time.

To sync properly, you would probably need to identify which number frame is being drawn during refresh, rather than relying on a timer to count the expected frames.

To do this, I cheat and use an on proximity event and attach a node to the foot. You can then calculate the bpm of the foot-falls hitting an attached plane. If I try use FPS for timing, it eventually goes out of sync just the same as you experienced.

If you don't want to use place-markers for the animation, you could try locking your frame-rate instead to see if that eliminates any timing/sync errors by refreshing the screen only after each frame is drawn. You should then be able to perfectly calculate the speed.

I may be wrong and possibly just talking BS. I did study animation at college but the maths is something I always struggle with - because I have a kind of dyslexia which specifically affects my understanding of time and numbers.

I do remember them talking about frames falling out of sync due to frame-skipping so it may be worth investigating further in case it points you in the right direction. You'll probably understand it more than I did.

Another animation trick which may be of help with syncing is that 3rd part Animation software usually includes a feature called "key-framing" which interpolates the animation by deleting certain (unnecessary) frames. An example would be using keyframes to convert/optimise a 600 FPS animation into a 30 Frame animation - this is a kind of deliberate frame-skipping for efficiency in gaming - as you're using less frames (at a slower FPS) to draw the same animation in the same time without making it look too jerky.


Robo
Guest
Quote
2021-06-18 11:55:53

Thats was a great comment thanks VP - I suspect your right and I need to change to 30 FPS instead...will try that and report back after some time.
Cheers !


VP
Guest
Quote
2021-06-18 15:16:33

Good luck buddy. I hope you manage to sort it.


just_in_case
Moderator
Quote
2021-06-20 06:10:19

I think @VP is right, lowering the animation frames maybe using 30 fps or 60 fps will do the job. Thanks @ VP for your wonderful reply, I learned a lot through this Post.

++++


veganpete
Registered User
Quote
2021-06-20 16:40:35

Thank you just_in_case

No problem at all, glad you found it helpful in some way. It all seems like a lifetime ago now, we were using an Amiga 1200 at the time, lol.

I get the same rush from animating in coppercube that I did with my beloved Amiga but now it's in 3D, not just sprites.


just_in_case
Moderator
Quote
2021-06-27 12:52:26

Just found that 300 Frames per second in coppercube is actually 0.3 frames per second in irredit/irrlicht properties.
irredit will give you the exact frames per ms, however its say framespersecond insteasd of framespermiliseconds.


Robo
Guest
Quote
2021-06-27 13:44:47

I found an easy way to modify animation FPS using Blender 2.79 to 30 FPS with just changing it from 30 to 300 (under Dimensions) then importing to CC then changing back to 30 again.

This didnt fix the problem unfortunately and trying to use the foot position check to pick up a full walk cycle before changing the "FramesPerSecond" as will reset the animation each time.

This was the only way - nothing else worked.
Some animations were a cut short slightly this way so maybe 60 FPS would be better..

Its working ok but needs some adjustments....thanks everyone..


Commodore
Guest
Quote
2021-07-02 15:25:18

My animation speedsetting attempts sofar went with:

ccbSetSceneNodeProperty(node, "FramesPerSecond", 24);

that works somewhat

but proves difficult in combining statements like:

ccbSetSceneNodeProperty(node, "Animation", "run");
ccbSetSceneNodeProperty(node, "FramesPerSecond", 24);

and then
ccbSetSceneNodeProperty(node, "Animation", "stand");
ccbSetSceneNodeProperty(node, "FramesPerSecond", 12);


Robo
Guest
Quote
2021-07-06 12:16:00

Commodore wrote:
and then
ccbSetSceneNodeProperty(node, "Animation", "stand");
ccbSetSceneNodeProperty(node, "FramesPerSecond", 12);

You need to have an animation blending between animations for best results then sometimes once done need to adjust that back to samller figure again - ie for walking or running.. will do a video on this soon...


just_in_case
Moderator
Quote
2021-07-06 17:47:40

I found myself in the same situation.. Need to calculate animation timings but there is no suitable way of doing this for now.


Robo
Guest
Quote
2021-07-18 12:13:11

wrote:
I found myself in the same situation.. Need to calculate animation timings but there is no suitable way of doing this for now.


Yeah, only the foot position as suggested by VP above sort of works to get a particular animation position...even this I had some trouble with... goodluck :)


VP
Guest
Quote
2021-07-19 08:16:59

To eliminate the problems when attaching proximity to feet, there are 3 essential things I found....

1- Add a cube proximity event to a plane (under the feet), rather than adding a sphere proximity to the feet. If you add a sphere proximity event to the feet, it means that only the centre of the terrain will trigger the footfalls (this will cause problems) - if you use a cube proximity event on the terrain instead, it will detect the centre of the foot (and avoid problems).

2- Make sure the cube proximity of the terrain is positioned exactly where the foot lands in the animation (slightly too high or too low will prevent it from working properly). If your terrain is not flat, add the cube proximity to a plane (childed to the player) just under its feet to avoid problems when the character moves up/down over the terrain.

3-Make sure that the cube proximity width/height are large enough so that the foot cannot travel straight through to the other side of the proximity trigger (otherwise it will trigger 2 events - one as the food comes down - and then again as it goes back up). Ideally you want the foot node to only just touch the proximity trigger.

It can take a while to set up with a bit of trial and error - but once it's set properly, it should be rock solid and reliable. The only trouble you'll get is when you switch animations; if the different animation adjusts the feet positions, it will cause trigger problems - in that case, you can work around it by creating a separate footstep plane for each animation and switch between them as you switch animations.

If you'd like to upload your model, I can set it up for you as an example.


just_in_case
Moderator
Quote
2021-07-19 08:23:47

Well, in my case my problem was solved long ago. I used a different approach. I wasn't changing fps during runtime so it is not causing problems so far.


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