TestQ3, can't jump when walking?

I copy/pasted the TestQ3 code into a sample FPS app. I noticed that, while I can jump when standing still, I cannot jump (or only very low for a very short time) when walking.



Is this a known bug or issue?

No, you sure you’re not falling and that you handle the key input correctly?

I have a PhysicsNode ‘Map’ which is just a huge flat box. I drop my character (PhysicsCharacterNode) and some other ‘characters’ (PhysicsNodes) on it. Dumping the camera coordinates indicates I am not falling.



Here’s the code: http://pastie.org/1370692



When standing still, I can jump. Then I run (W, Forward), I cannot jump. When I stop, sometimes I can jump, sometimes I cannot.

So you don’t handle the input correctly. You just set the buttons no matter if the key was pressed or released.

normen said:
So you don't handle the input correctly. You just set the buttons no matter if the key was pressed or released.


Not sure I follow you there, normen. `value` is a `boolean`, which is true when the button gets pressed and turns to false when released?

[java] if (binding.equals("Lefts")) {
if(value)
left=true;
else
left=false;[/java]

Would equal to:

[java] if (binding.equals("Lefts")) {
left = value[/java]

Or, am I missing your point here?

Thanks for your help.

Edit: I updated my onAction method to look like this, no difference in behaviour.

[java] public void onAction(String binding, boolean value, float tpf) {
if (binding.equals("StrafeLeft")) {
if(value)
left=true;
else
left=false;
} else if (binding.equals("StrafeRight")) {
if(value)
right = true;
else
right = false;
} else if (binding.equals("Forward")) {
if(value)
up = true;
else
up = false;
} else if (binding.equals("Backward")) {
if(value)
down = true;
else
down = false;
} else if (binding.equals("Jump")) {
playerNode.jump();
System.out.println("Jump!");
}
}[/java]

Yep, thats what I meant. There will have to be some change in whats happening, its two completely different things now…

normen said:
Yep, thats what I meant. There will have to be some change in whats happening, its two completely different things now..


Sorry, but I don't see how it's really different? `value` is a boolean, so a button is pushed or not and I set the left, right, up, down accordingly.

Anyway, I also changed the stepHeight from my PhysicsCharacterNode from 0.01f to 0.4f, and that fixed the jumping problem.

[java]playerNode = new PhysicsCharacterNode(capsule, 0.4f);[/java]

Before all your right, left, up and down values would be true after you pressed the key once…? Edit: oh, sorry, misread your code there.

No.



value is set to true when you push down the button and set to false when it’s released. I copy the value to my left,right,up,down vars and moving around works great. It was the jumping part that didn’t seem to work. But increasing the stepHeight of the PhysicsCharacterNode from 0.01f to 0.4 solves the issue.



Simply add this at the top of your onAction-method to see what I mean:



[java]System.out.println("-- " + binding + ": " + value);[/java]

Setting the stepHeight to 0.4 will only let your chatacter move upwards and downwards with increments of 0.4 which is 40centimeters in the physics engine and probably a bit too much. What is the scale of your world when you can use this value?? When using physics 1unit = 1m for the physics engine. Is your world roughly conforming to that? If yes, what is the smallest possible value for tpf that still works for you?

I don’t use any scale just right now, but I’m aiming for the unit = 1m (my player blocks are 1.8 units tall, for example).



I’ll test some values tomorrow and let you know how it pans out.