[Solved] Alternate ChaseCam and FlyCam


I want to change from fly to chase cam on keyboard event.

Doesn’t work, dunno why, heres the part that matters:


private void SetCams(){

if (debugMode) {


debugMode = false;

} else {


debugMode = true;



private void setFlycam() {



private void setChasecam() {


ChaseCamera chaseCam = new ChaseCamera(cam, player.getCharacter(), inputManager);


Doesn’t work as in… crash? Unexpected behavior?

It would help to know what you expect it to do and what you get. :slight_smile: Heap dump if you a crash or something.

I start in flycam ok, i switch to chase, and then i cant switch back to flycam.

you might need to enable and disable the chase cam also…


private boolean flyMode = false;

private ChaseCamera chaseCam ;

private void setupCams () {

chaseCam = new ChaseCamera(cam, player.getCharacter(), inputManager);



private void switchCams() {

flyMode = !flyMode;





I think this code is right, I’m at work so I cant test or check sorry.

I switch between chaseCam and flyCam in mTheoryGame, and when turning off the fly cam I needed to call chaseCam.setDragToRotate(false); I can’t remember exactly why I needed to call this, again because I’m at work I can’t check, but you may need it.

Good Luck!


Thank you,

Your code works perfect, actually, mine did as well the problem was actually with the inputs, i forgot the “&& !pressed” on the listener.

That’s why cam kept switching back.

for the posterity:


private ActionListener actionListener = new ActionListener(){

public void onAction(String binding, boolean pressed, float tpf){

if (binding.equals(“Toggle Cam”) && !pressed) {




also, am i supposed to mark this topic as fixed or something?

orgasmatron said:
also, am i supposed to mark this topic as fixed or something?

It's not a necessity, but it's appreciated. When searching and you see "Fixed", it puts a smile on one's face. ;)

No problems.

I try to edit my topic’s and add [Solved] or [Fixed] as a matter of courtesy, but you’ll find most people don’t bother… 'sup to you.

also, you needed "chaseCam.setDragToRotate(false); " because after turning of the flycam the mouse button appears due to the chasecam.

ahhh, that could explain why my next line of code is inputManager.setCursorVisible(false); :wink:

Figured it was worth a mention as it must have caught me out at some stage.