Game Development Community

Projectile explosion on client

by Howard Dortch · in Torque 3D Professional · 04/11/2014 (11:50 am) · 6 replies

I can't get the explosion to show up on the client side. Code says it should work but does not. Anything special I have to do ?

#1
04/16/2014 (4:24 pm)
Bump, anyone?
#2
04/17/2014 (5:07 pm)
Any more specific details? Have you made changes to the source code? Can you reproduce it in stock 3.5.1? If so that's a bug and we can pay official attention to it :)
#3
04/22/2014 (3:45 pm)
"function createExplosion()\n" is called out in the engine explosion.cpp but there is no actual function. I added one so all is well for me but yeah should be looked at.
#4
04/23/2014 (1:02 am)
Right, if you're trying to use this, unfortunately you've been misled. This code has never worked due to the way explosions are networked. This thread has some discussion, and this resource has a partial solution. There was a resource that used a netEVent to create an explosion for all clients but I can't seem to find it.

EDIT: There is now an issue for this.
#5
04/23/2014 (4:49 am)
When I ran into this issue I followed suit with ServerPlay2D and ServerPlay3D:

function ServerPlayExplosion(%position, %datablock)
{
   // Play the given explosion on every client.
   // The explosion will be transmitted as an event, not attached to any object.
   for(%idx = 0; %idx < ClientGroup.getCount(); %idx++)
   {
      %client = ClientGroup.getObject(%idx);
      commandToClient(%client, 'PlayExplosion', %position, %datablock.getId());
   }
}
 
function clientCmdPlayExplosion(%position, %effectDataBlock)
{
   if (isObject(%effectDataBlock))
   {
      new Explosion()
      {
         position = %position;
         dataBlock = %effectDataBlock;
      };
   }
}

Everywhere explosions are utilized they seem to be spawned client-side only. You can see this in the teleport functions as well.
#6
04/23/2014 (9:12 am)
I probably did the wrong thing here but it works

in Projectile.cpp I added this

void createExplosion(Point3F position, GameBaseData* data)
{
Explosion* pExplosion = NULL;
Point3F p = position;
Point3F n;
n.x = 0;
n.y = 1;
n.z = 0;
pExplosion = new Explosion;
pExplosion->onNewDataBlock(data, true);
MatrixF xform(true);
xform.setPosition(p);
pExplosion->setTransform(xform);
pExplosion->setInitialState(p, n);
pExplosion->registerObject();
}

// FROM THE CLIENT SCRIPT
ConsoleFunction(createExplosion, void, 3, 3, "pos, datablock")
{
Point3F position;
dSscanf(argv[1], "%f %f %f", &position.x, &position.y, &position.z);
ExplosionData* data;
Sim::findObject(argv[2], data);
createExplosion(position, data);
}

Thanks to all for reply...