I just started developing with jMonkeyEngine some days ago, but I’ve been programming with java for nearly 2 years. now I got stuck with a problem:
when I walk fastly forward, and there is an edge or a hill in my terrain, I lift off the ground, like in a car racing game, but when a human is walking, or running around, he normally doesn’t lift off the ground. How can I fix this problem?
I tried to get the Y coordinate of my terrain at the point weher I am, but there’s no method for that.
Sorry for my bad bad english, it’s not my first language.
It would be great if you could held me.
This is a non trivial problem,
-> For performance human legs needs to be abstracted, eg a capsule in case of humanoids often
-> A Capsule can sadly not maintian the logic legs can. (Eg very low to very high friction depending on how they move, the ability to dampen, or jump, ect)
A Very primitive solution would be to make a downnwards ray, and just apply additional force downward if its floating, and jump was not pressed the last x milliseconds.
OK, thanks first.
But how can I add an additional force downwards?
I’ve tried incresing the gravity, but even a gravity downwards of 2000 didn’t change anything.
Actually, if humans could move as fast as they normally do in video games then they would fly off the ground, too.
How is your capsule configured? I see so many code posted here with short fat midgets that only way 2 kg or so.
@Sumec99 said: I tried to get the Y coordinate of my terrain at the point weher I am, but there's no method for that.
Oh, thank you very much. I’ll try this out torrow. But if this method returns what it shall return, it is supposed to solve my problem
If you are just using terrain in the map, then getting the height of the terrain will work. But if there are other models in the scene then you will want to ray cast downwards in order to pick all objects below you. This is quite a quick process if the world is partitioned enough or if you have few objects.
OK, I solved it.
I didn’t find out how to initialize a TerrainQuad (honestly, I haven’t tried for long).
But then I got to know that when I increase the gravity after I add my characterControl to my physics space, it works. so as a result, it works fine, and it will also work in the scenario described in the last answer.