Question by 
               faheemmoolla · Oct 21, 2018 at 10:00 PM · 
                cameracamera-movementrotatearoundcamera movement  
              
 
              How to limit/Clamp RotateAround for camera movement?
I have a scene with a globe, where the camera is rotating around the globe. I need to clamp the position and rotation of this movement in certain instances of the game. I have tried several methods but none have worked. My code is below:
  private void LateUpdate()
     {     
         if (Input.GetMouseButtonDown(1))
             mouseStartPosition = GetMouseHit();          
 
         if (mouseStartPosition != null)
             DragPlanet();    
   
         if (Input.GetMouseButtonUp(1))
             StaticPlanet();  
 }
 
 public void RotateCamera(Vector3 dragStartPosition, Vector3 dragEndPosition)
     {
 
         //normalised for odd edges
         dragEndPosition = dragEndPosition.normalized *planetRadius;
         dragStartPosition = dragStartPosition.normalized * planetRadius;
 
         // Cross Product
         Vector3 cross = Vector3.Cross(dragEndPosition, dragStartPosition);
 
         // Angle for rotation
         float angle = Vector3.SignedAngle(dragEndPosition, dragStartPosition, cross);
 
 
         //Causes Rotation of angle around the vector from Cross product
         holderTransform.RotateAround(planet.transform.position, cross, angle);
     }
 
 
     private static Vector3? GetMouseHit()
     {
         RaycastHit hit;
         int layer_mask = LayerMask.GetMask("Planet"); //raycasting on the planet
         if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity, layer_mask))
         {
             return hit.point;
         }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                