Character too strong

tengil

11-07-2007 18:16:10

Hi!

I have the problem that my character is too strong. Even very heavy Body-Objects are pushed away easily when I'm going around and hit it - but I don't want this... How can I make the Character weaker?

cu
Tengil

betajaen

11-07-2007 18:31:18

Through a CharacterHitReporter

tengil

11-07-2007 19:11:31

Hi!

Ah, I forgot to say: We're using nxOgre 0.6...

In the past it was possible for me to change the weight or the damping of the body so that the character wasn't able to move it (and also joints keep together) - but now not anymore... was there a change someware before or at 0.6?

betajaen

11-07-2007 19:15:12

Not directly modifying NxOgre itself. The pushing of the Actor is actually done by the NxOgre character code and not PhysX, it's based of the tutorial code that comes with the PhysX SDK.

But you can certainly change the Character code to reduce the force of the push.

tengil

11-07-2007 20:27:34

Hi!

After reducing the force and seeing no effect I comment the line

actor.addForceAtLocalPos(hit.dir*coeff, NxVec3(0,0,0) , NX_IMPULSE);

completely out. The dynamic body-objects are moved nevertheless! To be sure that my modified dll is used I write a log-file with "hit-reports". Any idea?
NxF32 coeff = actor.getMass() * hit.length * 10.0f * 0.000000000000000001;
//actor.addForceAtPos(hit.dir*coeff,hit.controller->getActor()->getGlobalPosition());
//actor.addForceAtLocalPos(hit.dir*coeff, NxVec3(0,0,0) , NX_IMPULSE);
static Ogre::Log *log = Ogre::LogManager::getSingleton().createLog("c:\\log_nxogre.txt");
log->logMessage("TEST2 coeff = "+Ogre::StringConverter::toString(coeff));

betajaen

11-07-2007 20:50:59

Do you mean no effect as in the force is still strong, or the bodies aren't being moved?

If it's the latter, you've commented out the addForce function which uses coeff.

tengil

11-07-2007 21:08:52

The funny thing: Still too strong...

betajaen

11-07-2007 21:19:19

Try:

NxReal characterMass = 100;
NxF32 coeff = characterMass * hit.length;
actor.addForceAtPos(hit.dir * coeff,hit.controller->getActor()->getGlobalPosition());


Characters are Kinematic, they have no mass. So we pretend it does, 100 Kilograms in this case.

So I believe the product of the characterMass and the hit length the by the direction is the same as f=ma.

The code your working with uses the Actors Mass instead, so the Character uses "borrows" the Actors mass when it hits something!

tengil

12-07-2007 12:39:20

The happening of moving the bodies without executing the actor.addForceAtPos(..) or actor.addForceAtLocalPos(..) code wonders me...

It seems so that the shape of the character moves the bodies away. Shouldn't the movement of the shape stop if the character hit something? The character behaves like having infinite force to push dynamic bodies away.

betajaen

12-07-2007 12:53:42

That's weird. It shouldn't move at all if the addForce code isn't there.

Characters are a little different from normal actors. They don't do normal physics, they are known as kinematic. They don't respond to forces or acceleration. Which is why, there is specific gravity and force code.

tengil

12-07-2007 16:27:15

Yes, it's weird... Can you reproduce the problem on your system?

My Test-Project contains this:


My Test-Character:

nxOgre::character* mPlayer;
Ogre::SceneNode* node;
Ogre::Entity *testEntity;

blueprint<character> bp;
bp.setToDefault();
bp.setGravity(true);
bp.setSlopeLimit(45);
bp.setStep(0.3);
bp.setShapeAsCapsule(/*mShapeRadius*/ 0.3, /*mShapeHeight*/ 0.6);
bp.setMesh("");

mPlayer = (nxOgre::character*)bp.create("TestCharacter", Ogre::Vector3(14.0, 8.0, -20.50), mScene);
node = mPlayer->mNode->createChildSceneNode("TestCharacter#Node");
testEntity = mSceneMgr->createEntity("TestCharacter#Entity","Walk_01.mesh");
node->setPosition(Vector3(0.0,-0.6,0.0));
node->rotate(Quaternion(Radian(Degree(180)),Vector3::UNIT_Y));
node->attachObject(testEntity);



My Test-Body which shouldn't move - but it moves:

nxOgre::material *myTestMaterial = mScene->createMaterial("myTestMaterial",10000, 10000, 1);
mScene->createMaterialAlias("myTestMaterial", myTestMaterial);
nxOgre::cubeShape *myTestCubeShape = new cubeShape(1.0f,"material: myTestMaterial");

nxOgre::body *testBody = mScene->createBody(
"testBody",
"cube.1m.mesh",
new nxOgre::cubeShape(1.0f),
1.0f,
Ogre::Vector3(14.0, 8.0, -18.50)
);

testBody->setKinematic(false);
testBody->setDensity(100.1);
//testBody->mActor->setMass =
testBody->addShape(myTestCubeShape);
testBody->setAngularDamping(10);
testBody->setLinearDamping(10);
testBody->mEntity->setMaterialName("01_-_Default");

testBody->setGroup(mScene->findGroup(mScene->findGroupIndex("default")));



The modified nxOgre_character.cpp:

if (actor.isDynamic()) {
//NxF32 coeff = actor.getMass() * hit.length * 10.0f;
NxReal characterMass = 1;
NxF32 coeff = characterMass * hit.length ;
///////actor.addForceAtPos(hit.dir * coeff,hit.controller->getActor()->getGlobalPosition());
//actor.addForceAtPos(hit.dir*coeff,hit.controller->getActor()->getGlobalPosition());
//actor.addForceAtLocalPos(hit.dir*coeff, NxVec3(0,0,0) , NX_IMPULSE);
static Ogre::Log *log = Ogre::LogManager::getSingleton().createLog("c:\\log_nxogre.txt");
log->logMessage("TEST7 coeff = "+Ogre::StringConverter::toString(coeff));
}

tengil

13-07-2007 10:51:03

Hi!

Has somebody else the same problem? ...or better: A possible solution?

In my case the characters running even through locked doors without opening them before - the doors are pushed to the side... (they are locked with nxOgre::fixedJoint)
- Okey, in case of the doors it would be possible to lock the doors with mDoorBody->setKinematic(true), but then even i.e. explosions don't effect the doors... (everything would be much more complicated)

UPDATE:
The workaround with mDoorBody->setKinematic(true) doesn't work - the character goes straight through the door without any visible effect to the door or the character (it looks like the door is made of air...)

cu
Tengil

Fumé

14-07-2007 06:58:42

Hi betajaen and all,

tengil has been describing a problem we are having with the NxOgre character in his last postings.

We have a building with doors that are simulated with NxOgre. It was working fine but after a recent upgrade to a new NxOgre version our character became way to strong and is just pushing away the doors.

Pushing doors closed is quite what we intended so that doors could be closed accidentily. But now they are just ripped right out.

We basically only have the weekend to resolve this so I would appreciate any help with this issue.

Many thanks!

Markus

betajaen

14-07-2007 08:54:57

The only thing I can come up with is to dampen the forces and the movement vector of the character.

Obviously your doing it, but still.