Hi,
I want to change from fly to chase cam on keyboard event.
Doesn’t work, dunno why, heres the part that matters:
[java]
private void SetCams(){
if (debugMode) {
setChasecam();
debugMode = false;
} else {
setFlycam();
debugMode = true;
}
}
private void setFlycam() {
flyCam.setEnabled(true);
}
private void setChasecam() {
flyCam.setEnabled(false);
ChaseCamera chaseCam = new ChaseCamera(cam, player.getCharacter(), inputManager);
}[/java]
Doesn’t work as in… crash? Unexpected behavior?
It would help to know what you expect it to do and what you get. 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…
[java]
private boolean flyMode = false;
private ChaseCamera chaseCam ;
private void setupCams () {
chaseCam = new ChaseCamera(cam, player.getCharacter(), inputManager);
chaseCam.setEnabled(false);
}
private void switchCams() {
flyMode = !flyMode;
flyCam.setEnabled(flyMode);
chaseCam.setEnabled(!flyMode);
}
[/java]
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!
James
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:
[java]
private ActionListener actionListener = new ActionListener(){
public void onAction(String binding, boolean pressed, float tpf){
if (binding.equals(“Toggle Cam”) && !pressed) {
switchCams();
}}};
[/java]
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);
Figured it was worth a mention as it must have caught me out at some stage.