Can you share a video of the issue? That will help me understand, thank you!
Orbit around focused object after zoom
Hi Anthony,
Please see the attached video https://youtube.com/shorts/3ZZtVaJsLK8?feature=share
See how first when model is focused camera is orbiting around it, then I zoom into it few times and try to rotated around it now it rotated around some different point. I am trying to achieve orbit camera behaviour so I want it to keep rotating around the model just like it does when I focus on the model (before any zooming).
Thank you
Janna
Janna the camera is finding a point from the center of your screen, on the ground. this is the point it rotates around.
Here is a demo scene and script, to keep a target obj in focus while still allowing to zoom:
https://www.mediafire.com/file/g8hazlshkjq1yf3/orbit.unitypackage/file
Thanks Anthony, I just tried the demo and this is exactly what I want except I still want to be able to do panning, when panning happens camera would lose the focus of the object and continue focusing on the floor until I click to refocus on the object. I am going to look how to combine these two together, if you have any tips it would be great. I have noticed that you have used perspective camera instead of free camera in the orbit demo, I thought that perspective camera could be somewhat problematic if we end up not looking down on the floor plane?
Janna there is no direct way to detect that the user is translating but you can achieve this using two things:
This method will tell you if the user has 2 fingers on the screen, or uses an input to drag according to the input map on your component. You will need to make that method public to access it from outside.
IsInputMatching( InputMapFingerDrag.Translate )
Keep in mind that this will return true also if you zoom with 2 fingers.This will give you the center point on screen of all the fingers or pointers touching the screen. You can check if that points is moving over time to detect a translation:
CameraInputs.screenPointAnyFingerCountCenter
You can probably do it only with the 2nd code.
Let me know how it goes.
- Edited
I have a couple of questions regarding getting the orbit camera to work 1 )In your OrbitDemo if we try to pan the scene pans for a split of the second and then gets back into the original position, is it possible to disable panning at all? So we can only have zoom and rotate in the orbit mode? To avoid glitchy looking behaviour
2) In the same OrbitDemo if I move the Sphere up along Y direction the camera is no longer focusing on the Sphere but keeps focusing below. I have attached the photo. I have tried using Free Camera but got the same behaviour. Is there a way to adjust the camera so it is always looking at the centre of the target object? I thought this is what the code in OrbitDemo was doing but seems the camera is not going up.
https://ibb.co/kG49HZZ
I want to add that I tried to modify the code like this:
//cam.MoveCameraToInstant(targetObj.position.SetY(0));
cam.MoveCameraToInstant(targetObj.position);
It does help to get camera to the same height as the Sphere but the orbiting seems glitchy.
Thanks! Have a good vacation as well!
- Edited
Hi Anthony,
Thank you very much! I just tried it and it is looking really good, will be integrating into our project. I have noticed that in this package you sent there are lots of new changes, from the look on Camera Orbit script I just need that or do I need any changes that came in the updated project you sent?
I think I can see that there are changes for DisableTranslations that I don't have in my version, so I will need to use the one you provided, are you planning to include this code in the latest TCP update? Thanks