Help with moving up hill and falling through ground.

etsuja

12-02-2010 07:26:35

I'm making a game with a sphere world but I'm having trouble making it so the player is always standing with his head outwards from the sphere.

right now I'm doing this:

bod->getPositionOrientation(bodPos, bodOrient);
player->node->lookAt(Ogre::Vector3(0,0,0), Ogre::Node::TS_WORLD, Ogre::Vector3::NEGATIVE_UNIT_Y);
bod->setPositionOrientation( bodPos, player->node->getOrientation());


this works until I try moving up a hill, then my player falls through the ground.

this code is in my force callback btw.

So, I'm thinking I need to use an up vector, but I don't know what to use as an up vector so the players head is always pointing outwards from the sphere.

EDIT- Well I found what to make the up vector:
OgreNewt::BasicJoints::UpVector uv = OgreNewt::BasicJoints::UpVector(world, bod, player->node->getOrientation().y * Ogre::Vector3::UNIT_Y);
But my player is still falling through the ground when I try to go up hill.

etsuja

12-02-2010 10:16:01

Well, I kinda solved it, not exactly how I would want to though.

I was using an ellipsoid for my player body but now I'm using a box and he doesn't fall through the ground now.

if anyone has an idea of how I can get it working with an ellipsoid body feel free to share.

PJani

12-02-2010 10:23:03

you cant use directly setPositionOrientation for movement. Because creates jumps which do make falling thru the ground. Or going thru objects.

Try PlayerControler joint. I see you are using old newton 1.xx, because OgreNewt::BasicJoints::UpVector is only in old 1.xx and its depriciated. I recommend you switch to newton 2.xx its faster!

koirat

12-02-2010 11:14:12

Disable standard gravitation force on a body and set it manualy, gravitation direction is from your current position to the center of the sphere/world.
Make upvector joint that changes every time your position changes.

As mentioned already:
After making Body and attaching SceneNode to it do not use this SceneNode to set orientation and position.
Try in getting used to using forces from now on. :)

etsuja

12-02-2010 12:29:01

Thanks for the quick replies guys. Koirat, do you know the formula I'd use for the upvector? I don't know what I'd set it to without the scene node and the lookat function.

Chookaa

13-02-2010 02:25:36

are you using a treecollision for your hill/terrain ? i was having troubles with falling through my terrain treecollision until i started using a heightfield collision instead. to add a heightfield collision to your OgreNewt check out this viewtopic.php?f=4&t=11696

hope it helps

koirat

13-02-2010 10:39:34

@etsuja:
I do not know how to make this joint from custom joint. I have got it in MogreNewt implemented already.