Better Character Control Example

Hey everyone,

I had been using the old character control along with the sample tutorial code for 1st person collision. I have tried to convert it over using the new BetterCharacterControl but keep getting errors. I haven’t found any updated tutorials using the new control. Can someone provide me with a simple basic solution for the BetterCharacterControl ?

Danke :>

The forum might be able to help you with your errors if we knew what they were.

I was hoping someone had a working example but here you go :stuck_out_tongue:

[java] bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);

player = new BetterCharacterControl(1f,6f,1f);
player.setJumpForce(new Vector3f(0, 0, 0));
player.setGravity(new Vector3f(0, -10, 0));
player.warp(new Vector3f(0, 10, 0));

// bulletAppState.getPhysicsSpace().add(prison);
// bulletAppState.getPhysicsSpace().add(player);[/java]

The last two lines I have commented out throw an error when compiling.

@jojoofu said: I was hoping someone had a working example but here you go :P

[java] bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);

player = new BetterCharacterControl(1f,6f,1f);
player.setJumpForce(new Vector3f(0, 0, 0));
player.setGravity(new Vector3f(0, -10, 0));
player.warp(new Vector3f(0, 10, 0));

// bulletAppState.getPhysicsSpace().add(prison);
// bulletAppState.getPhysicsSpace().add(player);[/java]

The last two lines I have commented out throw an error when compiling.

Of the hundreds of possible errors… which error?

[java]

bulletAppState.getPhysicsSpace().add(prison);

[/java]

Null pointer exception on this line. Which I don’t understand because I already created both the bulletapp and prison objects.

Update,

Okay I figured out part of it. Forgot to add the control to my prison spatial.

[java]

prison.addControl(player);

[/java]

Now it will load but character control immediately begins floating upwards into the sky and ignores any collision.

For the future, when you are asked for the error… include all of the error information including the stack trace.

NullPointerExceptions are the singly easiest error to diagnose but impossible without the stack trace.

@pspeed said: For the future, when you are asked for the error... include all of the error information including the stack trace.

NullPointerExceptions are the singly easiest error to diagnose but impossible without the stack trace.

Will do , ty.

While we’re on the subject.

[java]

app.getCamera().setLocation(player.getPhysicsLocation());

[/java]

This is a line from the original collision tutorial. You use control location to set the camera location. However getPhysicsLocation is now protected. How do I get the controls location now ?