adding a character to a group

jchmack

10-03-2007 14:03:40


name+=Ogre::StringConverter::toString(objectcount);
objectcount++;

blueprint<character> bp;
bp.setToDefault();
bp.setGravity(false);
bp.setSlopeLimit(45);
bp.setStep(0.3);
bp.setShapeAsCapsule(CharacterRadius,CharacterHeight);
bp.setMesh("");

mPlayer = bp.create(name,InitialPosition,mScene);

//mPlayer->
//mBody->setGroup(mScene->findGroup("Players"));


Is there a way to set the group of a controlable character? So it doesn't bump in to certain objects? From what im seeing on intelisense there isn't .

Im trying to make an inactive group that doesnt collide with anything to save on cpu cycles.

betajaen

10-03-2007 18:35:34

It is, but that isn't the best way.

In controller.cpp, find this:

NxControllerAction character::oprismShapeHit(const NxControllerShapeHit& hit) {

mTouching = true;

if (mOneWayCollisions)
return NX_ACTION_NONE;

if (1 && hit.shape) {
NxCollisionGroup group = hit.shape->getGroup();
if (group!=owner->findGroupIndex("static")) {
NxActor& actor = hit.shape->getActor();
if (actor.isDynamic()) {


NxF32 coeff = actor.getMass() * hit.length * 10.0f;
actor.addForceAtLocalPos(hit.dir*coeff, NxVec3(0,0,0), NX_IMPULSE);

}
}
}

return NX_ACTION_NONE;
}


If you change it if ever so slighty:-



NxCollisionGroup group = hit.shape->getGroup();

if (group==owner->findGroupIndex("non-collide-group")) {
return NX_ACTION_NONE;
}

if (group!=owner->findGroupIndex("static")) {
....
}


That should work pretty well. I'll be implementing a proper solution to this in the future.