Variable updating when I don't want it to

I am adding a chasecam to my vehicle for a project i'm working on. I have it such that when I press F it starts following the vehicle and when I press R I want it to revert back to it's original position. To do this I created 4 variable to take in the cameras location, left axis, up axis, and direction when the chasecam is built and then when it is disabled I have the camera use those 4 variable to reset the frame. However the 4 variable are updating themselves while the chasecam is running and thus when I disable the chasecam the camera just stays in the last spot the chasecam is enabled. Does anybody know why the variables would update themselves even when I did not tell them to? Thanks, Here is the code for the chasecam.

   public void removechasecam(){

      try{

      chaser.setEnabled(false);

      cam.setFrame(cloc,cleft,cup,cdir);

      }

      catch (Exception chaser){};

      

      int width = settings.getWidth();

      int height = settings.getHeight();

       cam.setFrustumPerspective(45, width/height, 1,1000);

      cam.update();

      display.getRenderer().setCamera(cam);

   }

    public void buildChaseCamera(Node truck) {

       cloc = cam.getLocation();

       cup = cam.getUp();

       cdir = cam.getDirection();

       cleft = cam.getLeft();

        Vector3f targetOffset = new Vector3f(0,0,.5f);

        HashMap<String, Object> props = new HashMap<String, Object>();

        props.put(ChaseCamera.PROP_WORLDUPVECTOR, new Vector3f(0,0,.5f));

        props.put(ChaseCamera.PROP_STAYBEHINDTARGET, true);

        props.put(ThirdPersonMouseLook.PROP_MAXROLLOUT, "6");

        props.put(ThirdPersonMouseLook.PROP_MINROLLOUT, "3");

        props.put(ThirdPersonMouseLook.PROP_MAXASCENT, ""+45 * FastMath.DEG_TO_RAD);

        props.put(ChaseCamera.PROP_INITIALSPHERECOORDS, new Vector3f(5, 0, 30 * FastMath.DEG_TO_RAD));

        props.put(ChaseCamera.PROP_TARGETOFFSET, targetOffset);

        chaser = new ChaseCamera(cam, truck, props);

        chaser.setDampingK(48f);

        chaser.setMaxDistance(2f);

        chaser.setMinDistance(1.75f);

        chaser.setEnabled(true);

    }

Probably you're storing a reference to the camera's location vector, not a copy of its original values.

Try doing


cloc = new Vector3f(cam.getLocation());



etc. to store the values.

yep that did it. Thanks

or alternatively use the .clone() method on whatever you dont want to get the reference for!