I am using Dark GDK and Dark Physics in my project, I am trying to build ejecting cartridges into the firing sequence... I understand this maybe a Dark Physics issue but it may also be a dark gdk or coding issues... soory if its dark physics...
The problem is the model gets created and positioned correctly but the rigid body is not getting created correclty and I don't know why, I checked my code, and if I do a dbPhyGetRigidBodyExist on the object number I get a 0 meaning does not exists...
Any Ideas?
void RActor::spawnCartridge()
{
// get active loadout slot..
RLoadout *slot = getActiveLoadout();
// get weapon allocated to slot
RWeapon *weap = getActiveLoadout()->getWeapon();
// create new ejected cartride based on weapon definition
RCartridge* tempcart = new RCartridge(weap->getCartridge());
RVec3 limbpos;
if(tempcart->getIsValid())
{
// load cartridge array with new class for object expiration mamanger
cartridge[tempcart->getID()] = tempcart;
// position cartridge based on FPSC limb configuration
limbpos.X = dbLimbPositionX(slot->getHudModel(),slot->getHudbrasslimb()+5);
limbpos.Y = dbLimbPositionY(slot->getHudModel(),slot->getHudbrasslimb());
limbpos.Z = dbLimbPositionZ(slot->getHudModel(),slot->getHudbrasslimb());
dbPositionObject(tempcart->getID(),limbpos.X,limbpos.Y,limbpos.Z);
// rotate based on gun pivot object
dbSetObjectToObjectOrientation(tempcart->getID(),m_nGunObjectId);
// introduce random rotation
dbRollObjectLeft(tempcart->getID(),25+dbRnd(10));
// set scale to correct size
dbScaleObject(tempcart->getID(),0.2,0.2,0.2);
// add dark physics control to object
dbPhyMakeRigidBodyDynamicMesh(tempcart->getID());
// set body mass
dbPhySetRigidBodyMass(tempcart->getID(),10.0);
// show the ejected brass
dbShowObject(tempcart->getID());
// add ejecting force to cartridge
dbPhyAddRigidBodyForce(tempcart->getID(),2,0,0,1);
} else {
// if unable to create cartridge instance free heap...
delete tempcart;
}
}