Problems with Mob Spawn
by Aubrey Youngs · in Torque Game Builder · 09/27/2008 (4:34 pm) · 1 replies
Hi everyone. After much frustration, TDN and forum browsing, I'm still not getting my spawn function to work correctly.
This level is my "tutorial" level, so I do not want to use the spawn behaviors as I only want spawns to occur after a certain point, and then I want the spawns to be of random different mobs whose data is configured inside their corresponding datablock.
Right now, I am just trying to establish an initial spawn of one mob. The code I am currenlty calling is at the bottom.
I receive no errors. I have tried calling both from console and from a GUI button, but neither place anything on the screen.
Can someone please help me. I want to randomly spawn a random creature from different locations that follow a datablock configuration.
This is the code I am using to do so.
//spawn.cs
//9-27-08, ASY
// this script holds all of the functions for creature spawns
// there are 3 spawn points, so 3 different functions that will call
// spawn location
// this function initializes spawn and creature.
function SpawnMobs()
{
//add random creature mob at later date.
%spawnMob = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
datablock = devilDatablock;
};
spawnPoint1(%spawnMob);
}
//spawnPoint1
function spawnPoint1(%this)
{
if (!isObject(%this))
{
echo("not an object");
return;
}
else
{
echo("establishing spawn data");
%this.setImageMap(devilImageMap);
%this.setSize(56.391,78.185);
%this.setPositionX(-159.449);
%this.setPositionY(-263.608);
%this.setLinearVelocityX(0);
%this.setLinearVelocityY(0);
%this.setLayer(16);
}
//spawn location is set
// %this.setPosition(-159.449, -263.608);
}
This level is my "tutorial" level, so I do not want to use the spawn behaviors as I only want spawns to occur after a certain point, and then I want the spawns to be of random different mobs whose data is configured inside their corresponding datablock.
Right now, I am just trying to establish an initial spawn of one mob. The code I am currenlty calling is at the bottom.
I receive no errors. I have tried calling both from console and from a GUI button, but neither place anything on the screen.
Can someone please help me. I want to randomly spawn a random creature from different locations that follow a datablock configuration.
This is the code I am using to do so.
//spawn.cs
//9-27-08, ASY
// this script holds all of the functions for creature spawns
// there are 3 spawn points, so 3 different functions that will call
// spawn location
// this function initializes spawn and creature.
function SpawnMobs()
{
//add random creature mob at later date.
%spawnMob = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
datablock = devilDatablock;
};
spawnPoint1(%spawnMob);
}
//spawnPoint1
function spawnPoint1(%this)
{
if (!isObject(%this))
{
echo("not an object");
return;
}
else
{
echo("establishing spawn data");
%this.setImageMap(devilImageMap);
%this.setSize(56.391,78.185);
%this.setPositionX(-159.449);
%this.setPositionY(-263.608);
%this.setLinearVelocityX(0);
%this.setLinearVelocityY(0);
%this.setLayer(16);
}
//spawn location is set
// %this.setPosition(-159.449, -263.608);
}
About the author
Torque Owner Austin Reynolds