Attach CameraInputController to a moving object

Anything libgdx related goes here!

Attach CameraInputController to a moving object

Postby 9Dimitri » Sun Aug 13, 2017 9:26 am

Hello,

Is it possible to use the CameraInputController of libGDX, and also have the camera following a moving object?
I've tried setting the target field of the camera controller, but that didn't work. I feel like this should be possible, but I can't figure it out.

If not, then would it be hard to add this feature?
I know I can write my own camera controller, I just thought this would be a quite common use case.
9Dimitri
 
Posts: 3
Joined: Wed Oct 05, 2016 7:11 pm

Re: Attach CameraInputController to a moving object

Postby 9Dimitri » Sun Aug 13, 2017 11:11 am

Ok I've managed to get it working from this post:
viewtopic.php?f=11&t=25984&hilit=CameraInputController#p102425

Code: Select all
   Vector3 targetDiff = new Vector3(followTarget);
   targetDiff.sub(cameraController.target);

   camera.translate(targetDiff);
   cameraController.target.set(followTarget);
   camera.lookAt(followTarget);

   cameraController.update();


Now the only question is: should I try to commit this as an optional functionality of CameraInputController?
9Dimitri
 
Posts: 3
Joined: Wed Oct 05, 2016 7:11 pm


Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot] and 18 guests