Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
prototype.onAnimate = function(node, timeMs) Question

hadoken
Guest
Quote
2022-01-29 14:19:29

When scripting my custom behaviors for CopperCube I would like to ask a fundamental question about:
behavior_my_behavior.prototype.onAnimate = function(Node, timeMs)
under https://www.ambiera.com/coppercu... it says:
"timeMs: The current time of the scene in milliseconds. We use this to be able to smoothly move the cube: Every time, we store the current time we were called, so we can calculate the time difference between this and the last call, and move the scene node accordingly. But of course, there is no need to do this. If you prefer, you can also simply ignore this and create a frame dependent behavior".

The second .onAnimate param, in my case called timeMs gives me a nice counter to work with. What is timeMs then really referring to: simply the counted cycles of my behavior script (increasing faster on newer hardware, slower on older) or does it display truly elapsed milliseconds regardless of the users hardware speed thus kind of delta independent (I guess so from the docs half sentence "a frame dependent behavior", but maybe my understanding about it might be wrong)? I don't have two different powerful computers at hand to test the issue out at the moment.

So, if a print("timeMs = " + timeMs); would give me a frame independent counter that would be perfect for my purpose.

Thanks for any clarifying information.


csp-games
Guest
Quote
2022-01-29 22:32:27

Maybe I should better shut up because I don't know exactly whether I got this right, but in general MS, millisecs refers to the Systems timer that starts at zero when the PC is booted, then counts up1 every millisecond, as the name suggests, and (at least in 32 bit apps) has an integer overflow after 55 days, then it switches to - 2 billions and keeps on counting up.
If that "print timeMs" loop increases by a 1000 every second, then you know what it is.
It is not uncommon that one has to use millisecs as a parameter for an animation update, so the animator can forward the animation delta-adjusted, it does however also allow you to alter the speed of animations in a scalar way, like time-elapse or matrix bullet mode, slower or faster that realtime.


hadoken
Guest
Quote
2022-02-02 20:33:36

Thanks Dieter for your expertise on this. According to the discussion at https://ambiera.com/forum.php?t=...
For now I think I'll better stick with this to fulfill my delta/timer needs:
this.Time = new Date().getTime();
this.deltaTime = this.Time - this.lastTime;
this.lastTime = this.Time;

Or does maybe anyone else know additional facts about the subject? THX


csp-games
Guest
Quote
2022-02-03 01:27:24

That's the same, in plain Javascript, make sure it works for DirectX etc too.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Int?rnational" (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