BetterCharacterControl Camera and movement?

Hey Guys,
Im creating my own game right now, but I have two problems.

  1. I created an BetterCharacterControl and attached the Cam via

[java]ChaseCam = new ChaseCamera(cam, player, inputManager);[/java]

But now the cam is located at the Bottom of the Character. My question: How can I locate the Camera at the Face of my Model?

  1. I want to give the Character an movement (WASD), but dont now how to. With the CharacterControl I did it with KeyInput etc. Does it work the same way with a BetterCharacterControl? Or does it work different?

That was it for now, hope someone can help me :smiley:

The first two are more intuitive:

chaseCam.setDefaultHorizontalRotation(FastMath.DEG_TO_RAD * 90) // this rotates the camera by 90 degrees horizontally in the positive direction.

chaseCam.setDefaultVerticalRotation(-FastMath.DEG_TO_RAD * 90); // this rotates the camera by 90 degrees vertically in the negative direction.

Or

chaseCam.setDefaultHorizontalRotation(FastMath.PI/2);

chaseCam.setDefaultVerticalRotation(FastMath.PI/16);

make sure you do chaseCam.setSmoothMotion(false); when trying it because chaseCam.setSmoothMotion(true); is giving me a bug. The turn chaseCam.setSmoothMotion(true); back on when you are done testing and you know it works.

Hope it helps.

@Pixelapp said: The first two are more intuitive:

chaseCam.setDefaultHorizontalRotation(FastMath.DEG_TO_RAD * 90) // this rotates the camera by 90 degrees horizontally in the positive direction.

chaseCam.setDefaultVerticalRotation(-FastMath.DEG_TO_RAD * 90); // this rotates the camera by 90 degrees vertically in the negative direction.

Or

chaseCam.setDefaultHorizontalRotation(FastMath.PI/2);

chaseCam.setDefaultVerticalRotation(FastMath.PI/16);

make sure you do chaseCam.setSmoothMotion(false); when trying it because chaseCam.setSmoothMotion(true); is giving me a bug. The turn chaseCam.setSmoothMotion(true); back on when you are done testing and you know it works.

Hope it helps.

Doesnt works. Both show me completely different Perspectives. The first one shows me the Character from below, and the second shows the knees from the opposite site. I still cant move the mouse anyway. I dont understand why. Do I have to activate it somewhere on my BetterCharacterControl or my CapsuleCollisionShape?

@TaCqz Sorry, I think I didn’t understand your question in the first place. I was giving you the solution for chaseCam rotation in general. I guess you are talking about an specific problem.

@Pixelapp said: @TaCqz Sorry, I think I didn't understand your question in the first place. I was giving you the solution for chaseCam rotation in general. I guess you are talking about an specific problem.

Yes I am :smiley: See:

What i actually need to get fixed is the following:

  1. I want to be able to rotate the screen by moving my mouse.
  2. I want to get a first-person-view.
  3. I want to get my player walking.
  4. I want to do all this with BetterCharacterControl. I already did it with the CharacterControl, but now im changing to BetterCharacterControl.

To point your chase cam at the proper area, use something like this (you have all the ingredients to find how to do it on your own):

[java]cCam.setLookAtOffset(new Vector3f(0f, ((BoundingBox) player.getPlayerModelNode().getWorldBound()).getYExtent() * 2.15f, 0f));[/java]

If you’re using a normal camera, attach a node to the model’s origin, attach the cam to that and move the camera the proper offset up from there.

@madjack said: To point your chase cam at the proper area, use something like this (you have all the ingredients to find how to do it on your own):

[java]cCam.setLookAtOffset(new Vector3f(0f, ((BoundingBox) player.getPlayerModelNode().getWorldBound()).getYExtent() * 2.15f, 0f));[/java]

If you’re using a normal camera, attach a node to the model’s origin, attach the cam to that and move the camera the proper offset up from there.

How do I have to replace (getPlayerModelNode()) ? There is nothing like this. Im pretty new at jME3

Edit: Did it. But thats a thrid-person-view. What I want is a first-person-view.

The whole “third person” can be handled in different ways. Some games only use legs for the client’s model and extrapolate the correct eye (camera) location from that. Others use a whole body except for the head.

The process remains similar though. When moving it will be the model that moves. Models’ origin is usually at their feet/bottom/where it will be attached. So in the end you still have to put a node at that origin location (so the camera doesn’t look at the feet, etc) and offset the camera up where the eyes would be.