Regulating anim speed with delta timing?

Blitz3D Forums/Blitz3D Programming/Regulating anim speed with delta timing?

Zethrax(Posted 2004) [#1]
Hi, can anyone tell me how to go about setting the global animation speed parameter for UpdateWorld, for a program that uses delta timing to regulate gamespeed. I've tried using the delta timing multiplier variable for the 'anim_speed#' UpdateWorld parameter, but this causes the animations to run too slowly.

Basically I just want to regulate the speed of the animations so that they run at the same base speed on different systems.


sswift(Posted 2004) [#2]
If you are not using frame tweening, then you need not specify any value at all after updateworld.


Zethrax(Posted 2004) [#3]
I think you're thinking of the tween# parameter for RenderWorld, Sswift.

What I'm talking about is setting the value of the anim_speed# parameter for UpdateWorld to regulate game speed on computers running at different speeds, for a delta time regulated program.

I've tried running the C:\Program Files\Blitz3D\Samples\Blitz 3D Samples\mak\anim\anim.bb program both with and without a 'Delay( 100 ) in the main loop to simulate different speed computers, and there is a significant difference in the anim speed. So regulation of the base animation speed is definately required.


sswift(Posted 2004) [#4]
Axe:
I do not use any value on updateworld in my programs. However, I also do not use the standard animation commands. In fact, I don't even use animation. But if I DID use animation, then I would manually specify the animation frame I want for each entity rather than muck about with updateworld. Automatic animation updates might seem nice, but how often do you REALLY want an animation to play back at the same speed? Perhaps you want the player to pull put a new gun at the same speed every frame, but if you have a car, or a player running, you want the tires and the players legs to animate at the same speed they're moving. So you need to control that manually. I beleive the command I'm thinking of is called SetAnimTime.

If you really want to use the updateworld command though, I can't help you. I'm looking at the command right now myself, and frankly these help instructions for this particular command are atrociously bad. It says the normal value is 1. That is the normal playback rate. What is the normal playback rate? Is that stored in the file? Does the file specify that the animation should play back at 60 frames per second? And if it plays back at 60 frames per second always no matter what, why would you need to change the value for updateworld to get the animation to play back at the right speed? Clearly that is not what it is doing, if in fact the animation speed is changing on you, because the animation speed should be tied to the timer and not to how many times you call renderworld.

So I don't know what is going on. It's too confusing. Sorry! :-) I suggest you animate stuff manually. I don't use that tweening crap for the same reason. It is much simpler to use delta time and animate things manually.


Rottbott(Posted 2004) [#5]
I think if you set the animation frame manually, you won't get any smooth transition between animations.


sswift(Posted 2004) [#6]
I think that only applies to md2 animations. B3D's you can set the anim frame to any float value.


martonic(Posted 2004) [#7]
Axeman:

Set the speeds using the "Animate" command so the animations look right on the computer you're testing on.

Then, set "Test_FPS" to the typical FPS of your game on that same computer.

Then, use the following code, or something equivalent, to calibrate the animations.


Global Max_FPS = 60	; Maximum FPS on any computer
Global Test_FPS = 35    ; Typical FPS on test computer
Global FramePeriod = 1000 / Max_FPS

Global FrameDiff#
Global FrameFactor#
Global FPS#		; Actual FPS on any computer


Previous = FrameTime = MilliSecs() - FramePeriod

;Main Loop

Repeat
	Now = MilliSecs()
	FrameDiff = Now - Previous
	Previous = Now
	FPS = 1000.0/FrameDiff
	FrameFactor = Float(Test_FPS)/FPS

; Frame limiter
	While (FrameTime + FramePeriod) > MilliSecs()
		Delay 1
	Wend
	FrameTime = MilliSecs()

	UpdateGame()
	
	If FrameFactor > 3.0 FrameFactor = 3.0 ;a "reasonable limit"
	UpdateWorld(FrameFactor)
	RenderWorld
	Flip False
Forever



jhocking(Posted 2004) [#8]
The anim_speed parameter is very easy to use with delta time. You just use the delta time multiplier, adjusted for a scale factor. As in, if the animation is playing too slow when you use the multiplier straight, try doubling it:

UpdateWorld delta*2



"I beleive the command I'm thinking of is called SetAnimTime"

Hee hee. I still giggle over having set a bad precedent by successfully "lobbying" (ie. whining to) Mark to add that command. Poor Mark; even though the Feature Requests forum is gone, people are still super annoying about demanding new features.

I use the standard Animate command a lot, but I also use SetAnimTime a lot. Basically, any time I don't need the exact control of SetAnimTime I use Animate because you can just fire and forget. For example, for simple looping animations on background objects I just call Animate once immediately after loading the object and never have to worry about that object's animation any more.


sswift(Posted 2004) [#9]
"Hee hee. I still giggle over having set a bad precedent by successfully "lobbying" (ie. whining to) Mark to add that command. Poor Mark; even though the Feature Requests forum is gone, people are still super annoying about demanding new features."

What are you talking about? I lobbied for that feature myself, and it's anything but bad precendent. That is a great feature and one Blitz should have had from the start. It is absurd to think that all that time Blitz had no way to set an animation to a specific frame, and even now, it has no way to do so for MD2 animations... which is the only thing preventing my shadow system from casting shadows from MD2 models.

Yeah there are a lot of bad feature requests out there, but this was a good one and very neccessesary because without it, some things are difficult, annoying, or impossible.


Zethrax(Posted 2004) [#10]
Thanks for the info, people. I'll have a play with SetAnimTime for game animations.

What I need this for, though, is for a model viewer/game world editor program. I just need the animations to play automatically at a standardized rate so that the user can see what animations are available for a model. I'll try the suggestions above.