PhysicsSpace and Gravity

Hi all,

I try to put some gravity in my game. But I have a problem.

I want a normal gravity of a Vector3f(0, -2, 0). But the player gravity must be set to Vector3f(0, -10, 0).

First, I set the gravity from the state :
[java]bulletAppState.getPhysicsSpace().setGravity(new Vector3f(0, -2, 0));[/java]

And after, I create the control and link it with the bulletAppState
[java]playerControl = new BetterCharacterControl(1.5f, 4, 30f);
playerControl.setJumpForce(new Vector3f(0, 300, 0));
playerControl.setGravity(new Vector3f(0, -10, 0));
playerNode.addControl(playerControl);
bulletAppState.getPhysicsSpace().add(playerControl);[/java]

The problem is that I can put any value, it doesn’t work… The gravity stays (0, -2, 0) for the player.

What am i doing wrong ?

Thank you for your answer.

OK, problem solved !

It is working if i write the setGravity() after the bulletAppState.getPhysicsSpace().add(playerControl);

[java]playerControl = new BetterCharacterControl(1.5f, 4, 30f);
playerControl.setJumpForce(new Vector3f(0, 300, 0));
playerNode.addControl(playerControl);
bulletAppState.getPhysicsSpace().add(playerControl);
playerControl.setGravity(new Vector3f(0, -10, 0));[/java]

Can just someone explain me why ???

Thank a lot :slight_smile:

The physicspace has no real gravity,
as far as I know bullet just sets it as a default gravity when the object is first added.

…as written in the javadoc

Ok… Sorry… I was reading the book and i have not thinking about the basis: RTFJavadoc…