NoodlesOnMyBack
13-10-2008 20:08:33
Im trying to make my own Character implementation, but it crashes when i touch other actors.
[EDIT]
I fixed it, a very stupid mistake with an actor overlapping another one.
[/EDIT]
Creation of character:
I put a static box as a floor:
The Hit report Class:
When i simulate:
I can never detect the collision here:
if(collisionFlags & NXCC_COLLISION_DOWN)
And i think it crashes when the character overlaps with the other actor, if i put breaks in the Hit report class, they never get notified either... going nuts here... any comment would be very well received...
[EDIT]
I fixed it, a very stupid mistake with an actor overlapping another one.
[/EDIT]
Creation of character:
NxCapsuleControllerDesc ccdesc;
static NxF32 gInitialRadius = 0.5f;
static NxF32 gInitialHeight = 2.0f;
ccdesc.setToDefault();
ccdesc.height = gInitialHeight * 1;
ccdesc.radius = gInitialRadius * 1;
ccdesc.position.set(0,0,0); //-60,90,-50
ccdesc.callback = &gControllerHitReport; //this
ccdesc.upDirection = NX_Y;
ccdesc.slopeLimit = 0;
ccdesc.skinWidth = 0.2f;
ccdesc.stepOffset = gInitialRadius * 0.5 * 1;
mController = mControllerManager->createController(ownerScene, ccdesc);
mController->setCollision(true);
mActor = mController->getActor();
mActor->setGroup(COLLIDABLE_MASK);
I put a static box as a floor:
NxBoxShapeDesc boxDesc;
boxDesc.dimensions = NxVec3(NxF32(1000), NxF32(10), NxF32(1000));
boxDesc.group = GROUP_COLLIDABLE_NON_PUSHABLE;
NxActorDesc actorDesc;
actorDesc.shapes.pushBack(&boxDesc);
actorDesc.globalPose.t = NxVec3(0,-400,0);
NxActor* newActor = ownerScene->createActor(actorDesc);
The Hit report Class:
class ControllerHitReport : public NxUserControllerHitReport
{
public:
virtual NxControllerAction onShapeHit(const NxControllerShapeHit& hit)
{
if(1 && hit.shape)
{
}
return NX_ACTION_NONE;
}
virtual NxControllerAction onControllerHit(const NxControllersHit& hit)
{
return NX_ACTION_NONE;
}
} gControllerHitReport;
When i simulate:
mMovementVector = (mDirection * mNextMovement ) * time * mSpeed;
NxU32 collisionFlags;
mController->move(newPos, COLLIDABLE_MASK, 0.000001f, collisionFlags, 1.0f);
NxU32 r = mCollisionFlags;
if(collisionFlags & NXCC_COLLISION_DOWN) { // & NXCC_COLLISION_DOWN
mGravity = false;
}
mNextMovement = Ogre::Vector3::ZERO;
mControllerManager->updateControllers();
I can never detect the collision here:
if(collisionFlags & NXCC_COLLISION_DOWN)
And i think it crashes when the character overlaps with the other actor, if i put breaks in the Hit report class, they never get notified either... going nuts here... any comment would be very well received...