Game Development Community

Speeding up/Slow down

by baylor wetzel · in Torque Game Builder · 11/25/2007 (10:45 pm) · 2 replies

Is there a built in way to control the speed of the game?

Right now the speed up/slown buttons change the value of moveTo but that doesn't affect other items and it doesn't affect moveTo until the next move command is called. It works OK for us but it would be nice if there were some built in way to say "run 3x as fast until i say otherwise"

btw, i use this in an strategy game my students use to understand AI. When trying to understand a battle, they turn the speed down and when they've figured it out, they crank up the speed to see how it all turns out

#1
11/26/2007 (12:05 am)
I don't think there is a built in way of doing it, but you could 1/2 ass it =P

function SomeClass::speedMod(%this, ... , %speedScale)
{
	%objectList  = %scenegraph.getSceneObjectList();
	%objectCount = getWordCount(%objectList);
	
	for (%i = 0; %i < %objectCount; %i++)
	{
		%object = getWord(%objectList, %i);
		if (%object.isSomeCondition)
		{
			%velocity = %object.getLinearVelocity();
			%velocity.x *= %speedScale;
			%velocity.y *= %speedScale;
			%object.setLinearVelocity(%velocity);
		}
	}
}
#2
11/26/2007 (1:20 pm)
For normal speed:
$timescale = 1

For twice the speed:
$timescale = 2

For half speed:
$timescale = 0.5


And so on.