Camera height and walking problems

Hi,



for my game I’m using two different camera angles (first and third person). The game starts from a third person point of view, for this I use the chaseCam. I followed the “walking characters (wip)” tutorial for this and I discovered a problem here, when I rotate the chaseCam to a point straight above the model, the character won’t move anymore, just the animation is playing.



The second problem is a setting height problem with the flycam. With a keystroke I move from one camera to the other. and when changing to the firstperson view I use the location of the model to go to the correct position. But the camera is set in the middle of the collision shape, I tried to add some height by doing add(0,300, 0) (the 300 is for a noticeable change of height) But it stays at the same height as before.



So my questions are, what am I doing wrong? :s

Without seeing the actual code we cant tell what you do wrong, you can tell us all day you add 0,300,0 :wink: Whats actually strange is that you talk about flyCam and ChaseCam at the same time. The flyCam should be disabled when you use a ChaseCam. The problem with the cam above the char is that you cannot derive a direction vector from that camera position, so the character is not moved. A solution would be to check if the cam is pointing straight down and if that is so then use the characters walkDirection instead of the cam x/z direction.

for the first issue, this is because the character moves in the direction of the camera. But when you look from above, the direction of the cam is straight into the grounds. So your character don’t move because it can’t go into the ground with the physic on control.



What you should do, instead of using the direction of the cam directly is to set the y component of the direction to 0 and then normalize the direction.



characterDir.set(cam.getDirection());

characterDir.setY(0);

characterDir.normalize();

character.setWalkDirection(characterDir);

you are right normen, I should have added code :stuck_out_tongue:

so here it is :slight_smile:



[java]

private void setupCamera() {

gamePointer.getFlyByCamera().setEnabled(false);

chaseCam = new ChaseCamera(gamePointer.getCamera(), model, gamePointer.getInputManager());

chaseCam.setEnabled(true);

chaseCam.setDragToRotate(false);

chaseCam.setLookAtOffset(new Vector3f(0,3,0));

}



void changeCamPos() {

if(!firstPerson){

//zet camera naar firstperson

System.out.println(“firstperson!”);

firstPerson = true;



gamePointer.getFlyByCamera().setEnabled(true);

gamePointer.getFlyByCamera().setDragToRotate(false);



gamePointer.getCamera().setLocation(character.getPhysicsLocation().add(0,300, 0));

chaseCam.setEnabled(false);



}else{

//zet camera naar thirdperson

System.out.println(“thirdperson!”);

firstPerson = false;

gamePointer.getFlyByCamera().setEnabled(false);

chaseCam.setEnabled(true);

chaseCam.setLookAtOffset(new Vector3f(0,3,0));

chaseCam.setDragToRotate(false);

}

}[/java]



as you can see i disabled the cam’s when I don’t use them, but I think this isn’t the proper way of using them ain’t it?