Game Development Community

Toqure won't register my Debris object...

by Brandon Fogerty · in Torque 3D Professional · 02/18/2010 (12:17 am) · 4 replies

So I defined a debris datablock like so

ParticleTest.cs
datablock DebrisData(ParticleTest)
{
   render2D = true;
   texture = "~/data/particles/shiny2.bmp";
   elasticity = 0.5;
   numBounces = 5;
   bounceVariance = 2;
   friction = 0;
   velocity = 20.0;
   velocityVariance = 0.5;
   terminalVelocity = 30;
   gravModifier = -1.0;
   lifetime = 240.0;
   lifetimeVariance = 0;
};

In my server's game.cs I did the following

game.cs
exec("~/data/shapes/particles/ParticleTest.cs");

...

function GameConnection::createPlayer(%this, %spawnPoint)
{
    .....

   // Give the client control of the player
   %this.player = %player;
   %this.setControlObject(%player);
   
   
   %particle = new Debris()
   {
      dataBlock = ParticleTest;
      position = "1 1 1";
   };
   
   %particle.position = %player.getPosition();
}

When the code gets executed, Torque gives me the following error...

"Register object failed for object (null) of class Debris."

What more do I need to do to register the object? Thanks!

#1
02/18/2010 (4:13 pm)

This is a bug in the Debris class code. It's initPersistFields method is missing the call to the parent's initPersistFields.

To correct this, add

Parent::initPersistFields();

as the last statement in Debris::initPersistFields.
#2
02/18/2010 (8:53 pm)
It doesn't seem like that is the solution. My Debris::initPersistFields method had the parent call as a first statement in that method like so,

void DebrisData::initPersistFields()
{
   Parent::initPersistFields();

However I did try placing the parent call at the end of the method but I still get the same error... =(

Any other ideas?
#3
02/18/2010 (8:59 pm)
Actually, it didn't work. I no longer see the error message pop up in the console but my particle effect is still not visible...
#4
02/19/2010 (5:51 pm)
I don't know if this is your exact problem, but Debris objects should only be allocated client-side. That script is executed server-side. It might actually work anyway in a singleplayer situation but definitely not in real multiplayer.