My issue is this: I am making a simple game where a cube moves around in a big field. The problem is, when the cube jumps, it stops moving forward. Now I would like it to keep the forward velocity. If there is no other way, I could make it so that force is applied to the cube while running in the air, but that would be unrealistic. Here is the .blend
1 Answer
If you enable "Add" on all your motion actuators, you will get behavior closer to what you'd expect. With the logic how you have it now, when you push W, A, S, D or Space, the corresponding motion actuator sets the new location of the cube, based on the old location. The differences in location is what you have in the motion actuators. Because of this, only one can run at once - they are all trying to run at the same time, and they are all trying to set the cube's new location based on what they have filled in, which is different for each object.
However, if you set them to add, each one will add or subtract from the cube's location, instead of trying to set it. When you press Space, while holding forward, instead of the BGE taking the cubes location, adding to it along the Z, and setting the new location, it will simply add to the cube's Z location, creating the expected behavior.
In addition to having your cube able to move and jump at the same time, if you enable the "Add" setting on your other motion actuators, your cube will be able to move diagonally.
-
$\begingroup$ Once you get enough (15) reputation, you can also upvote this answer :) $\endgroup$ Commented Jul 16, 2016 at 22:02
-
$\begingroup$ I can upvote it now, it just doesn't show. It's still recorded $\endgroup$ Commented Jul 16, 2016 at 22:08