Health Kit Spawn Question - Help
by Samarie · in Torque Game Engine · 10/14/2009 (3:55 pm) · 3 replies
Hey guys,
In the FPS Starter kit, does anyone know how to make the health kit spawn at different places when you load the game? I want to create 6 spawn spheres and have the health kit spawn at those different locations when the player loads the game. Just like when you load the FPS Starter kit and the player spawns at different locations, I want the health kit to do the same thing.
In the FPS Starter kit, does anyone know how to make the health kit spawn at different places when you load the game? I want to create 6 spawn spheres and have the health kit spawn at those different locations when the player loads the game. Just like when you load the FPS Starter kit and the player spawns at different locations, I want the health kit to do the same thing.
About the author
I'm an undergraduate student studying game and simulation programming at a university.
#2
as well as a rotate = 1 that rotates the object.
10/14/2009 (6:45 pm)
there should be a respawn = 1 or something like thatas well as a rotate = 1 that rotates the object.
#3
GameConnection::spawnPlayer()
GameConnection::createPlayer()
pickSpawnPoint()
and create new functions, something like this:
This may or may not work, but it should point you in the right direction. :)
10/14/2009 (8:31 pm)
Take note of these three functions:(inside of game.cs)GameConnection::spawnPlayer()
GameConnection::createPlayer()
pickSpawnPoint()
and create new functions, something like this:
//-----------------------------------------------------------------------------
function GameConnection::spawnHealthPacks(%this)
{
// Combination create health and drop it somewhere
%healthspawnPoint = pickHealthSpawnPoints();
%this.createHealthPacks(%healthspawnPoint);
}
//-----------------------------------------------------------------------------
function GameConnection::createHealthPacks(%this, %healthspawnPoint)
{
// Create the health object
%health = new Item() { // this may be incorrect. (ItemData)???
dataBlock = HealthKit;
};
MissionCleanup.add(%health);
// place health...
%health.setTransform(%healthspawnPoint);
}
//-----------------------------------------------------------------------------
// Support functions
//-----------------------------------------------------------------------------
function pickHealthSpawnPoint()
{
%groupName = "MissionGroup/HealthDropPoints"; //note this as well
%group = nameToID(%groupName);
if (%group != -1) {
%count = %group.getCount();
if (%count != 0) {
%index = getRandom(%count-1);
%spawn = %group.getObject(%index);
return %spawn.getTransform();
}
else
error("No health spawn points found in " @ %groupName);
}
else
error("Missing health spawn points group " @ %groupName);
// Could be no spawn points, in which case we'll stick the
// player at the center of the world.
return "0 0 300 1 0 0 0";
}This may or may not work, but it should point you in the right direction. :)
Torque Owner Donnie-Hutson-Jr