C
CaptainBaxter

  • 24 Jan
  • Joined Oct 11, 2024
  • Hi Anthony,

    Thank you for your response. I basically want to update the script so that the pan movement in aligned to the camera X/Y rather than aligning it to the surface you are clicking on. I would like to keep all of the other functionality so this is the only part of the script I have changed. I am still getting some strange behaviour with the zoom, it will fly off to extreme distances and the rotation will sometimes move the camera to the wrong location.

    I think I understand your logic correctly, there's quite a lot of abstraction so it's hard to follow, but I believe you are using the offset value as the location of the pivot point for the orbit controls then the distance is the distance from that point to the camera? You then calculate the angle from that pivot point?

    Many thanks

    • Hi,

      I'm having difficulty adapting your FreeCamera script. Currently the camera relies on clicking the mesh of the scene to translate the camera, however, I am trying to change the script so that it simply moves the camera along it's X/Y axis by getting the delta from the screenspace for finger/pointer movement. I can easily enough move the camera to the new target position but it's unclear what needs to be done about distance and offset?

      `
      finalOffset = newWorldPointCameraCenterClamped;
      finalDistance = CalculateClampedDistance(finalPosition, newWorldPointCameraCenter, minMaxDistance);
      //finalPosition = CalculatePosition(newWorldPointCameraCenterClamped, finalRotation, finalDistance);

                      var scaleFactor = -0.5f;
      
                      var x = Input.GetAxis("Mouse X") * scaleFactor ;
                      var y = Input.GetAxis("Mouse Y") * scaleFactor ;
                      
                      var move = transform.right.normalized * x + transform.up.normalized * y;
                      var target = transform.position + move;
      
                      finalPosition = target;
      
                      CalculateInertia();

      `

      Could you please advise?

      Many thanks