Spawn Object Bug (Engine Code Fix Inside)
by Matthew Hoesterey · in Torque X 2D · 12/03/2009 (12:26 am) · 3 replies
Their is a bug in the spawner object. It will ignore minSpawnTime the first time it spawns an object.
To fix modify the OnRegister() in the T2DSpawnObject class as follows
To fix modify the OnRegister() in the T2DSpawnObject class as follows
public override bool OnRegister()
{
if (!base.OnRegister())
return false;
if (_spawnOnce)
{
if (_spawnEnabled)
{
DoSpawn();
MarkForDelete = true;
}
}
else
{
Assert.Fatal(_maxSpawnTime >= _minSpawnTime, "T2DSpawnObject::ProcessTick: MaxSpawnTime is less than MinSpawnTime!");
if (_maxSpawnTime < _minSpawnTime)
_maxSpawnTime = _minSpawnTime;
// generate a new spawn time
_nextSpawn = TorqueUtil.GetRandomFloat(_minSpawnTime, _maxSpawnTime);
SetTicking();
}
return true;
}
#2
It also has the advantage of being attached to an object that will keep spawning until destroyed, like in Gauntlet.
02/20/2010 (6:30 am)
I created my own spawner, its in my game kit, it works correctly and has a CC version for those of you who are using the CC freebie.It also has the advantage of being attached to an object that will keep spawning until destroyed, like in Gauntlet.
#3
02/20/2010 (3:00 pm)
yeah i checked out your spawner, I couldn't get it to work for a template but maybe I was doing something wrong. I'll try attaching it to an object though lol.
Torque Owner Darthuvius