Issue with Camera Script Control in Cesium: Rotating around a Point on the Ground

I’m encountering an issue with camera script control in Cesium within Unity. My goal is to implement a camera interaction where, while the dynamic camera is continuously centered at the origin of Unity coordinates, holding down the right mouse button allows me to cast a ray onto the ground, obtaining the collision point A. At this point, I want the camera to rotate around point A using Unity’s method.transform.RotateAround

The challenge arises because as the camera moves, the center point of Unity also changes dynamically, impacting the intended behavior of this mouse interaction. I am seeking guidance on how to address this issue and achieve the desired effect.
Steps to Reproduce:

  1. Keep the dynamic camera centered at the Unity origin.
  2. Hold down the right mouse button to cast a ray onto the ground.
  3. Obtain the collision point A.
  4. Attempt to rotate the camera around point A using .transform.RotateAround

Expected Result: The camera smoothly rotates around the collision point A on the ground, despite the dynamic movement of the camera.

Actual Result: Due to the dynamic change in Unity’s center point, the camera’s rotation around point A is not achieving the expected behavior.

Questions:

  1. How can I maintain the intended camera rotation around point A, considering the dynamic movement of the camera and Unity’s changing center point?
  2. Are there alternative methods or approaches to achieve this camera interaction without being affected by changes in Unity’s center point?

Note: I appreciate any insights or suggestions on resolving this issue and optimizing the camera script control for the described scenario.

1 Like

Hey @jh007,

How far away is Point A from the camera, typically? The simplest suggestion I could offer is to disable the CesiumOriginShift component on the camera while it’s rotating, then re-enable it when you’re done. However, if it’s a larger scale rotation, I’m not certain it will function as well. Let me know whether that solution works!

2 Likes