Wierd behaivour when re-setting the chasecameras maxdistance

Hi!



When my character is throwing a grenade, I want the chasecam to be fixed with 1m in distance from the character. So you get sort of, in the neck close up so you can aim better.

Problem is, nomather how I try to solve it, I get the problem that when it has zoomed, I end up far above the character.

Because I didn’t find a “setDistanceToTarget” method, I tried the following:

[java]if (value){

if (binding.equals(“MMB”)){

previousCameraDistance = ClientGame.chaseCam.getDistanceToTarget();

ClientGame.chaseCam.setMinDistance(0);

ClientGame.chaseCam.setMaxDistance(1f);

ClientGame.chaseCam.setLookAtOffset(ClientGame.app.getCam().getDirection().mult(-.4f));

ClientGame.app.getCamera().setLocation(ClientGame.getPlayer().getViewnode().getWorldTranslation().subtract(ClientGame.app.getCam().getDirection()));

}

} else{

if (binding.equals(“MMB”)){

ClientGame.getPlayer().throwGrenade();

ClientGame.chaseCam.setMaxDistance(previousCameraDistance+1);

ClientGame.chaseCam.setMinDistance(previousCameraDistance);

ClientGame.resetChaseCam();

}

}



}[/java]



Value is if the middle mouse button is up or not.

So it should also zoom back to the previous distance had before clicking once done.

I’m uploading a video about it on youtube so you get my point but it seems to take a while

so I’ll post the video once it’s done.

About 26% done now…



But how can I set the camera to be behind the character using chasecam without getting this error?

Heres a video illustration:

http://www.youtube.com/watch?v=QJRTOuhLjbo

try setDefaultDistance to change the distance.

it does what your want, it’s designed to be the default distance of the camera at start, but it should work.

1 Like

Nice!

It works :smiley:

Thanks!!