NxOgre::Character is not respoding to collision! Normal?

spacegaier

08-03-2008 17:30:32

I've created a plane (NxOgre::Body), a cubish NxOgre::Body and a NxOgre::Character.

The two cubes (the character is also a cube) are standing on the plane.

Now I let fall down many other bodies (SphereShapes) on this plane -> the cubish body is affected by them (pushed around on the plane). But the character is only affecting the other obejcts (the spheres are bouncing away or I can push the cubish body around with my character).

Is that normal? Do I have to handle the collision effects on my character manually by my own and if I do so how (some keywords)?

NxOgre::Body *gr = m_pNxScene->createBody("Plane.mesh", new NxOgre::CubeShape(50,0.1f,50),Vector3(0,0,0), "static: yes");
gr->getNode()->showBoundingBox(true);
NxOgre::Body *b = m_pNxScene->createBody("cube.1m.mesh", new NxOgre::CubeShape(1,1,1), Vector3(0,20,0), "Mass: 10");

NxOgre::CharacterParams params;
params.setToDefault();
params.CT_Box;
params.fromString("mass: 1");
params.fromString("material: characterMat");

m_pNxScene->createMaterial("characterMat")->setAll(0.5f, 0.5f, 0.5f);
m_pPlayer1Character = m_pNxScene->createCharacter("Player", NxOgre::Pose(Vector3(0,5,0),Quaternion::IDENTITY),params);
m_pPlayer1Character->createNode();
Entity* ent = m_pSceneMgr->createEntity("PlayerEntity","cube.1m.mesh");
m_pPlayer1Character->getNode()->attachObject(ent);

m_pPlayer1Character->setMovementVectorController(new myMovement());


My spheres:

NxOgre::Body * b;
NxOgre::SphereShape * s = new NxOgre::SphereShape(1);
b = m_pNxScene->createBody("sphere.2m.mesh", s, m_pCamera->getPosition(), "mass: 20, material: name");
b->addForce(m_pCamera->getDirection()*550,NX_IMPULSE);

betajaen

08-03-2008 18:20:54

Your character params are wrong and just plain weird, use this:

CharacterParams cp;
cp.setToDefault();
cp.mType = CharacterParams::CT_Box;
cp.mDimensions.set(0.5f, 2.0f, 0.5f);


Characters don't use Materials, and your node/entity stuff for that character is a little strange. Use this instead:

mCharacter->createNode();
mCharacter->attachMesh("cube.1m.mesh");
mCharacter->getNode()->scale(0.5f, 2.0f, 0.5f);

spacegaier

08-03-2008 18:34:00

What was the intend for creating the function fromString() for the params? Or better why shouldn't it be used in my case to give more params to my character (or does this has to be done in another way)?

betajaen

08-03-2008 19:14:30

fromString, resets the all the variables of that param to default before hand. FromString is used by the String constructor. It's also slightly slower than just setting the variables normally.

spacegaier

08-03-2008 19:27:15

fromString, resets the all the variables of that param to default before hand

What does "before hand" mean?

betajaen

08-03-2008 19:28:31

Using fromString(...) will undo any changes to the Param if you use it.

spacegaier

08-03-2008 19:38:47

All right and what is this mDimensions represent? The size of the Shape of the character?

params.mDimensions.set(0.5f, 2.0f, 0.5f);

betajaen

08-03-2008 20:03:21

Yes.

spacegaier

08-03-2008 20:05:37

But the character is still not pushed from the plane! Why?

betajaen

08-03-2008 20:08:38

I'm not understanding what you are trying to do. Posts some screenshots.

spacegaier

08-03-2008 20:54:10

I'll just make a video of it.

spacegaier

08-03-2008 21:00:51

Here it is: http://web218.mis22.de/demo.avi

The red cube is the NxOgre::Body. He is pushed around by the spheres falling down from the sky. The blue one, is my character which is not affected by the spheres only the other way round: He affects the spheres which bounces back.

How can I reach that the characters also shows reactions to the spheres?

dbrock

08-03-2008 21:05:28

characters are special, you can't move them around by throwing shapes at them. you should read the physx documentation about character controllers.

spacegaier

08-03-2008 21:08:35

But how can I make them react?

betajaen

08-03-2008 21:10:13

It's a kinematic actor (does not behave like normal physical bodies), so making it react is a little hard. You need to capture the event of being hit; calculate the force then the directional vector to move.

dbrock

08-03-2008 21:13:02

Some people have character animations when they get hit, or have hitboxes (actors) that simulate rag dolls when the player dies. I'm not sure how to achieve what you're trying to do.

Why do you want your player to get knocked over anyway? That would probably piss me off as a gamer lol. Unless it was a Rocket Jump ;).

spacegaier

08-03-2008 21:15:35

But that seems to be really dufficult as I also have to make sure that the speed decreases and the characters stop again.

And how can it get this hit events?