Loading spawn point from file
by Nmuta Jones · in Torque Game Engine · 07/16/2008 (9:44 pm) · 1 replies
I have a single player game.
In my game I am using triggers for 'checkpoints'. When you hit a trigger, I am writing a line like this to file:
My save file is called 'save2.cs'.
So if you die, when you respawn, you should respawn at $savedata::transform.
So how do I load this data back in dynamically?
In game.cs I have tried to hook it right into the respawn function, since its a single player game.
At the beginning of game.cs I do
exec("./../../client/save2.cs");
then I do
It's not working....it's not spawning the player at the check point, but even it it did,
that's no good, because I need it to always read from the file to decide on the new spawn point each time.
I tried to EXEC the save2.cs file inside of the spawnPlayer function, but that's not working either, and I also did not know if its wise or safe to exec a file inside of a function like that. Any help would be greatly appreciated. thanks.
In my game I am using triggers for 'checkpoints'. When you hit a trigger, I am writing a line like this to file:
$savedata::transform = "456.385 302.441 220.923 0 0 1 2.69064";
My save file is called 'save2.cs'.
So if you die, when you respawn, you should respawn at $savedata::transform.
So how do I load this data back in dynamically?
In game.cs I have tried to hook it right into the respawn function, since its a single player game.
At the beginning of game.cs I do
exec("./../../client/save2.cs");
then I do
function GameConnection::spawnPlayer(%this)
{
%spawnPoint = pickSpawnPoint();
//old code
//%this.createPlayer(%spawnPoint);
%newspawn=$savedata::transform;
%this.createPlayer(%newspawn);
}It's not working....it's not spawning the player at the check point, but even it it did,
that's no good, because I need it to always read from the file to decide on the new spawn point each time.
I tried to EXEC the save2.cs file inside of the spawnPlayer function, but that's not working either, and I also did not know if its wise or safe to exec a file inside of a function like that. Any help would be greatly appreciated. thanks.
About the author
Lead Developer for MediaBreeze Multimedia
Torque Owner Nmuta Jones