Mount ShapeBase on Vehicle
by Alexander Gugau · in Torque Game Engine · 06/26/2002 (3:08 pm) · 6 replies
I want to start the game with a vehicle and a mounted turret. I derived a turret class
from ShapeBase. Then I'm trying to create the vehicle like this (from the racing mod)
But only the Vehicle shows up and no turret. Am I completely wrong or am I just missing
a code line or two? Must I set a control object for the turret?
Thanks
Alex
from ShapeBase. Then I'm trying to create the vehicle like this (from the racing mod)
function GameConnection::createPlayer(%this, %spawnPoint)
{
if (%this.player > 0) {
error( "Attempting to create an angus ghost!" );
}
%player = new HoverVehicle() {
dataBlock = DefaultHoverTank;
client = %this;
};
MissionCleanup.add(%player);
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the tank
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the tank
%this.player = %player;
%this.setControlObject(%player);
// added code here
%turret = new Turret()
{
dataBlock = TurretBase;
};
MissionCleanup.add(%turret);
%player.mountObject(%turret, 0);
}But only the Vehicle shows up and no turret. Am I completely wrong or am I just missing
a code line or two? Must I set a control object for the turret?
Thanks
Alex
#2
(dont laugh, happened to me a while back...drove me nuts LOL)
06/26/2002 (11:22 pm)
Have you checked your datablock to ensure that it is ok? Try placing one of these turrets in the game next to your vehicle, it might be somehting as simple as a really minature model?(dont laugh, happened to me a while back...drove me nuts LOL)
#3
yes I tried that and it showed up. But I want to mount the weapons on the turret. Therefore I think it has to be ShapeBase. Btw, is it possible to rotate a ShapeBaseImage around the mount point?
Daniel,
I think the datablock is ok. It is added to the scenegraph but it is never rendered (put breakpoints) there. I played around with the control object, if I set the vehicle as the turret's control object, I get the processTick but playGui is not displayed.
Alex
06/27/2002 (12:51 am)
Stefan,yes I tried that and it showed up. But I want to mount the weapons on the turret. Therefore I think it has to be ShapeBase. Btw, is it possible to rotate a ShapeBaseImage around the mount point?
Daniel,
I think the datablock is ok. It is added to the scenegraph but it is never rendered (put breakpoints) there. I played around with the control object, if I set the vehicle as the turret's control object, I get the processTick but playGui is not displayed.
Alex
#4
What I've done is created three parts for the turret:
TurretBody and TurretHead derived from ShapeBase and TurretBarrel which is a ShapeBaseImage.
What Im trying is to mount the TurretHead onto my TurretBody and then ofcourse TurretBarrel on TurretHead.
Im having no problems mounting the TurretBarrel (ShapeBaseImage) to the TurretHead, but I cant mount the TurretHead to TurretBody. When I try TurretHead spawns at position (0,0,0). Just for fun try hitting F8 and fly below the terrain until you reach position (0,0,0) there you might see the missing Turret.
If you fix the bug PLEASE email me at: hempel@os.dk thanx! and good luck...(you'll gonna need it =D)
08/07/2002 (3:53 am)
Im having almost the excact same problem!What I've done is created three parts for the turret:
TurretBody and TurretHead derived from ShapeBase and TurretBarrel which is a ShapeBaseImage.
What Im trying is to mount the TurretHead onto my TurretBody and then ofcourse TurretBarrel on TurretHead.
Im having no problems mounting the TurretBarrel (ShapeBaseImage) to the TurretHead, but I cant mount the TurretHead to TurretBody. When I try TurretHead spawns at position (0,0,0). Just for fun try hitting F8 and fly below the terrain until you reach position (0,0,0) there you might see the missing Turret.
If you fix the bug PLEASE email me at: hempel@os.dk thanx! and good luck...(you'll gonna need it =D)
#5
Alex
08/08/2002 (6:38 am)
That's the way I've done it. I have my code not right here. I'm going to post later.Alex
#6
That's what I have done to achieve this. The turret is my control object.
good luck
Alex
08/08/2002 (11:19 am)
I think your problem is that you mounted the turret head only on the server side, but didn't send this information to the client.That's what I have done to achieve this. The turret is my control object.
bool Turret::writePacketData(GameConnection* client, BitStream* stream)
{
bool ret = Parent::writePacketData(client, stream);
if(ret && mControlObject)
{
S32 gIndex = client->getGhostIndex(mControlObject);
if(stream->writeFlag(gIndex != -1))
{
stream->writeInt(gIndex, 10);
ret = mControlObject->writePacketData(client, stream);
}
else // control object does not exist on other side
ret = false;
}
else
stream->writeFlag(false);
return ret;
}
void Turret::readPacketData(GameConnection* client, BitStream* stream)
{
Parent::readPacketData(client, stream);
if(stream->readFlag())
{
S32 gIndex = stream->readInt(10);
ShapeBase* obj = static_cast<ShapeBase*>(client->resolveGhost(gIndex));
setControlObject(obj);
obj->readPacketData(client, stream);
}
else
setControlObject(0);
}good luck
Alex
Associate Stefan Beffy Moises