I'm trying to make a world map in Unity that contains a rotating globe with landing sites on the perimeter. What I want is that when a player clicks on the landing site the globe rotates so that the landing site is centered. I've been trying to find the right way to use the Quaternion class but not much luck.
Here is my latest attempt which doesn't work. The landing sites are parented to the globe but the camera and globe are separate.
void Update()
{
if (_selectedLandingSite != null)
{
var rotation = Quaternion.FromToRotation(_selectedLandingSite.transform.localPosition, MainPlanet.transform.forward);
var trans = Game.Game.Instance.MainCamera.gameObject.transform;
var lookDirection = new Vector3(trans.position.x, trans.position.y, trans.position.z);
lookDirection = rotation * lookDirection;
var _lookRotation = Quaternion.LookRotation(_selectedLandingSite.transform.localPosition);
//rotate us over time according to speed until we are in the required rotation
MainPlanet.transform.rotation = Quaternion.Slerp(transform.rotation, _lookRotation, Time.deltaTime * 1);
//MainPlanet.transform.rotation =
// Quaternion.RotateTowards(MainPlanet.transform.rotation, _targetRotation, 1);
}
}