# How do I get a RigidBodys velocity in the given vector?

Hi,

I have a rigidbodycontrol guy that can walk and jump and stuff.

Problem is that he runs on a world so small.

So small that when he jumps, he enters orbits around the planet XD

Anyhow, thats why I need to do some special stuff. So I need to remove all velocity and add velocity for gravity and movement.

Problem is, when removing velocity I loose the gravitys size. If he was falling fast to the ground, the whole velocity is removed.

So what I have to do is isolate the velocity of the gravity, given a vector.

So I have the bodys velocity. And I have the direction of the gravity.

How can I isolate all the bodys velocity flowing the the gravitys direction?

You really should use a CharacterControl for a player. CharacterControl has functions like setGravity() and setFallSpeed() which is what I think you’re talking about. Along with that use a CapsuleCollisionShape so your character can walk up stairs and things.

It’s all explained really well in this tutorial:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_collision

Thanks

Yes indeed, charactercontrol works great! But not in my current game

My game is a small 3d planet and you can walk “upsidedown” and then charactercontrol does not work so well.

Heres an image of the game:

http://i48.tinypic.com/fbg841.png

Due to this small size world, you can jump into orbit and thats why I need to isolate the gravity

But thanks anyways for your suggestion

Actually I think (I don’t use physics myself) all you need to do is each frame set the gravity in the character control to point towards the center of the world.

Add “friction” so objects slow down over time and that will remove the orbit problem.

Yes I thought so too! But when an objects starts falling and when it has fallen for a second, the velocity is different.

This magnitude of gravity I need to know in order to add gravity for each frame. Otherwise the velocity generated by gravity will be close to zero because it is given no time to build up…

But in reality that is so too, thats why sattellites proceed to fall over the edge of the world if you accelerate them quickly enough

I think I’ll just save the time from when he does not touch ground until he does. Then simply multiply the gravity force by that number.

Will probably create some bugs but I’ll fix them as they come…