Game Development Community

Pausing a path without resetting it?

by Dave Calabrese · in Torque Game Builder · 02/06/2007 (10:24 pm) · 4 replies

Is it possible to 'pause' the movement of an object along a path? I've tried a number of ways of doing this, such as setting the pathSpeed to '0', but everything I do always resets the position of the object to 'node 0' on my path. Is it possible to just 'pause' the object at its current position, then have it start up where it stopped at a later point in time?

#1
02/07/2007 (12:18 am)
There is no way to do this trick except pause the integration of pathed object in path in C++.
#2
02/08/2007 (7:30 am)
You can just pause the object itself... use the object.setPaused(1) method. This halts the object. When the object.setPaused(0) is used, the object resumes it's trip down the path. It will not change any of your nodes.


Hope that helps you out!
#3
02/08/2007 (8:46 am)
I have tried using the 'setPaused' method, unfortunately nothing ever happens when I use it. I am running the latest released build (1.1.3 I think...), does this only work in a more recent beta, or does it possibly only work on some objects? I was trying it on a simple StaticSprite that was attached to a path.
#4
02/08/2007 (11:48 am)
The method works fine on the most recent release. You do have a name assigned to the staticSprite so it is accessible from script, right?

Here is a quick way to get it working. Sorry if this is too simplistic, but maybe someone else can use this in the future.

To test the setPaused() method out, just make a new project and create a single static sprite object, and a path. Assign a name to the static sprite in the "scripting" tab. Call it "sprite1" for example.

Make at least 2 points for the path. Now mount sprite1 to the path. Save your level, and start up your game. You should see the sprite moving along the path. If not, make sure the sprite is mounted to the path.

Now open up the console window "~", and type the following...

sprite1.setPaused(1);

Close the console, and you will see the sprite has stopped moving. Open the console back up and type...

sprite1.setPaused(0);

Close the console, and you will see the sprite has resumed moving.

You can use any function you wish (actionmap, mouse event, etc.) to execute the setPaused from script.