This is my problem: I have a spherical-ish world that is represented by a TriangleMesh. I am manually applying the force of gravity for each interact-able physics body in the direction of towards the centre of spherical-ish world. Now the problem is that the main controllable character (represented by a sphere to JigLibX) needs to have their velocity constrained but only in the directions that are tangential to the surface of the spherical world. Therefore I need the effects of gravity to still be applied to the main character while their velocity is constrained in directions that are orthogonal to the gravity vector. Basically how do I do this?
What I have tried:
- The first thing I have tried was to apply the gravity force like normal to the character body and then with a bit of maths constrain the velocity of the body by manipulating the velocity component of the body directly. This did not work because although the velocity was constrained, the force of gravity is being ignored internally by JigLibX. I'm unsure why but I'm guessing if you manipulate the velocity manually forces do not get applied?
- The second thing I tried was to apply the velocity of gravity to the character body instead of as a force. This approach works but in the future I will need to apply other forces to the character and using velocities will not be appropriate, essentially this puts a lot of extra work on me for how the game should be designed - which JigLibX should take care of. Also I've noticed that sometimes my character body falls through the world TriangleMesh sometimes when using this approach.
- The final thing I have looked at but not sure how to implement it ConstraintVelocity class. I'm guessing this is what I want but I could not find good usage of it. Now I know this works but how would I go about constrain-ing the velocity of a body in 2 directions; directions that are continuously changing according to the surface of the world geometry?
Thanks for any help