Extending FlyByCamera

Hello there!

I’m quite new with jme, and compared to most of you I’d guess, a newbie programmer so I might just be missing something.



Anyways, I’m currently working on how the camera should react in a simple FPS game. At this point, instead of creating a whole class for controlling it, I’d like to just extend the FlyByCamera since I currently only have to change a couple of lines to achieve my result. But I have an issue doing this - more exactly making the constructor.



The constructor for FlyByCamera looks like this:



public FlyByCamera(Camera cam){

this.cam = cam;

initialUpVec = cam.getUp().clone();

}



So in the extending class I’d just make a controller like this:



public FPSCam(Camera cam){

this.cam = cam;

initialUpVec = cam.getUp().clone();

}



But compiling I get an error telling me that it can’t find a contructor method in FlyByCamera taking no variables. Well, obviously it can’t since it takes an instance of Camera in only it’s constructor. But why would it tell me this when I explicitely put a Camera in my contructor?

Is it my knowledge of java which totally fails me or does this actually make sense to anyone?



Tyvm

You have to call super(cam), this way the superclass constructor will be executed and you dont need to copy its calls.

Oh… Yeah, you’re right. Thank you so much. :slight_smile: