Character falling down

s0lidnuts

17-07-2007 00:46:21

I set up a character (NxOgre::Character) but it seems to not obey the scene gravity, it falls down like 3 times less than the other objects.
(It's probably another stupid thing, but I don't have time to read about PhysX neither NxOgre righhtt now xD

Thanks in advance.

betajaen

17-07-2007 09:28:25

The Character's Actor is kinematic so gravity does not apply to it. So NxOgre "fakes" it for you. Obviously the formula is wrong.

It's found in, CharacterController::move(). But you can override the move formula of a character by sub-classing the CharacterMovementVectorController class in your code, pass on the instance to Character (myCharacter->setMovementVectorController(...)) and adjust "g" to your own settings.

s0lidnuts

17-07-2007 21:16:22

Once I change the vectorController the character stops responding to the direction, when I move the char with 'W' it moves itself on the axis based on the world, not on himself. Let me know if you didn't understood what I tried to say =X

yoshin

26-07-2007 01:43:27

Hello. I am having excessive trouble making my character controller fall according to gravity (as in gravitational accelaration). I did all the CharacterMovementVectorController stuff, and implemented the "move" function, using the basic formula that betajaen offers in this thread (a few posts down) :

http://www.ogre3d.org/phpBB2addons/view ... ection+rot

By looking at the formula, it's obvious that the character will fall at a constant speed (because g is plugged directly in there). I've tried to modify the equation so that it actually falls correctly (with an acceleration of g). I think the following formula should work, though I have not been getting the correct results:

NxVec3 grav = NxVec3(0, old_y, 0) + NxVec3(0, -9.8, 0) * Math::Abs(t - old_t);
out = (direction.rot(moveVector) * mySpeed) * t + grav;
old_t = t;
old_y = grav.y;


old_t and old_y just keep track of the previous frame's time and y-speed, respectively, so that I can calculate the appropriate change in y-speed for the current frame.

From my formula, you can probably tell that I am assuming the passed "t" is in seconds, and that it is the number of seconds since the character controller was created. For some reason, when I don't absolute value the change in time, it moves much more slowly than when i do... and in general, my formula results in a constant falling speed...

Is the move function supposed to calculate the resulting ABSOLUTE position, or the resulting DELTA position. Cuz if it's supposed to calculate the absolute position, i can see why my code doesn't work. Otherwise, I am stumped. :(

Thanks in advance.

betajaen

26-07-2007 09:53:48

I'm pretty sure it's Delta position. I haven't been in the Character Controller code for a while now, I'm working on something else which is top secret.

However, my formula is based upon the character controller tutorials that Ageia provide. Although they are demos, I wouldn't expect them to be totally accurate. What I wouldn't give to get my hands on the CellFactor or Unreal Engine 2007 source code right now. ;)