Game Development Community

ShapeBase object id numbers changing after animation

by Bryan "daerid" Ross · in Torque Game Engine · 02/05/2002 (11:15 pm) · 7 replies

Really hard to explain here. I'll try by showing some sample code:

void ShapeBase::setTeam(U32 team)
{
  Con::printf("Setting object %u team to %u",getId(),team);
  mTeam = team;
}
U32 ShapeBase::getTeam()
{
  return mTeam;
}

// Hud to render team indicators
// render method

..... some code ......

GameConnection *conn = GameConnection::getServerConnection();

for(SimSetIterator itr(conn); *itr; ++itr)
{
  // Test whether or not to render the image
  if((*itr)->getType() & ShapeBaseObjectType)
  {
    ShapeBase *shape = static_cast<ShapeBase*>(*itr);
    // test if we should render the image (simplified)
    if(shape->getTeam()!=0)
    {
      Con::printf("Rendering Team indicator for shape: %u, team %u", shape->getId(),shape->getTeam());
    }
  }
}


Now, in my game scripts, I have (something like) this
function playerSpawned(%client)
{
  %player = new Player() {}; // blah blah blah
  %player.setTeam(%client.team);
}

function playerDied(%player)
{
  %player.setTeam(0); // 0 means don't render the image
}

Ok, got it? Didn't think so =)

Ok, so I start up the game, and I spawn.

Check the console, I have something like:

Setting object 1570 team to 1

Ok, so I hit ctrl+k to suicide, and check the console

Setting object 1570 team to 0

Ok, so I respawn, and walk up to my corpse, and check the console, expecting everything all fine and dandy ( meaning NO console spam, because I'm assuming that the team for my corpse object was properly set to 0 ) and I get something like this:

Rendering Team indicator for shape: 1572, team 1
Rendering Team indicator for shape: 1572, team 1
Rendering Team indicator for shape: 1572, team 1
Rendering Team indicator for shape: 1572, team 1
Rendering Team indicator for shape: 1572, team 1 Rendering Team indicator for shape: 1572, team 1
etc....

Is that supposed to happen? It seems like the ID for that object just jumped. I can't for the life of me figure out why, and it's screwing me up. Does it have something to do with the death animation?

#1
02/06/2002 (2:22 am)
I think the new ID is because you spawned a new player.

Check in the mission editor, look at the id of the corpse, and look at the id on the newly spawned player.


Dark
#2
02/06/2002 (1:35 pm)
Does sound like 1572 is the id of your new player object, and 1570 (now dead) was correctly set to team 0.
#3
02/08/2002 (8:57 am)
Well the thing is, the way the hud works, it spits out the ID number of the object it's rendering, not the control object.

And the dead object IS 1572, not 1570, because the console spam stops as soon as the corpse fades out.

Tim, do new objects get created during animation sequences?
#4
02/08/2002 (9:40 am)
Animation is all internal to the objects, no new objects are created.
#5
02/11/2002 (10:13 am)
Damn. Then this is just weird. The ID # for the object is changing in the console after the new player object is respawned.

I know that the new number isn't my new player object, because when I call methods on the new id #, those methods act on the corpse. I can't figure this out :|
#6
02/11/2002 (11:37 am)
Bryan, it does sound like there is a problem with client versus server objects and/or player vs. corpse objects. I can't really tell from the snippets you posted what exactly the problem is, but if you'd like me to take a look just shoot me the files you changed and I'll see if I can't point you in the right direction.

Dave Myers
21-6 Productions
#7
02/11/2002 (10:12 pm)
Awesome!

I'm gonna try using this on the straight demo app, instead of our all tweaked and changed Legends build.

If I get the same thing, I'll shoot the code over to ya :)