[Solved] Character falls through the ground.

gbisocoli

03-10-2011 21:28:29

Hi, I'm implementing Character Controller (NxOgre + Critter: 1.7.x Buggy Swires) and I'm having trouble with the character, it falls through the ground. Here is part of the code (based on tutorial 1201.h):

Using this:
enum ControllerShapeGroups
{
NonCollidable = 0, // Things that the character controller can go through such as Ghosts or tiny
// objects like small rocks.
Walls = 1, // Walls, Floors and other static geometry that can't be moved.
Objects = 2 // Boxes, Barrels and other dynamic parts of the scene that can be moved by pushing.
};


I create the plane like this:
NxOgre::PlaneGeometryDescription nxPlaneDesc;
nxPlaneDesc.mGroup= Walls; // for the Character not to fall through the ground.
mNxOgreScene->createSceneGeometry(nxPlaneDesc);


and the creation of the character is this:
HumanPlayerBase(Critter::RenderSystem* rs, NxOgre::Scene* nxos): PlayerBase(rs, nxos)
{
Critter::AnimatedCharacterDescription desc;
desc.mShape = NxOgre::SimpleCapsule(5+0.5+0.1,2);
desc.mCollisionMask = (Walls << 1) | (Objects << 1);
desc.mMaxGroundSpeed = 17.0f;
desc.setJumpVelocityFromMaxHeight(mNxOgreScene->getGravity().y, 0.75f);

mCharacter = mRenderSystem->createAnimatedCharacter(Ogre::Vector3(0,40,0), Ogre::Radian(0), "sinbad.mesh", desc);
mCharacter->setInput(mCharacterInputHelper);
}


So, this is a little different to the tutorial, for example in the tutorial the floor is created like this:
// Fake Floor
BoxDescription fake_floor_desc(250,1,250);
fake_floor_desc.mGroup = Walls;
mScene->createSceneGeometry(fake_floor_desc, Vec3(0,-0.5,0));
[...]
// Plane creation
mScene->createSceneGeometry(NxOgre::PlaneGeometryDescription());


It seems there are two different floors on the tutorial, is there a way of using just one floor? Like I did? Am I missing something? The character just appears and falls to the ground.

betajaen

03-10-2011 21:46:31

Ground planes and Character Colliders don't collide. It's a bug/feature of PhysX, hence the need for a large plane like box.

gbisocoli

03-10-2011 22:15:45

Bug/feature, interesting... :lol:

Ok, then I'll have to create two "floors" :?

Thank you, betajaen.

gbisocoli

03-10-2011 22:58:14

Sorry for the double post but other things appeared:

1. When I put this line "mCharacter->setInput(mCharacterInputHelper);" on the Constructor it doesn't move, but when I put it on "bool keyPressed(const OIS::KeyEvent& evt)" it moves :shock: it is necessary to do that sentence every frame?

2. I have two characters, the first moves (mCharacterInputHelper I think) and the other doesn't (the shape) :o apparently they are not connected (?)

EDIT:: Solved, they were just stupid mistakes i made :D