I would like to have tanks that move around on a planet (a sphere).

Depending on where the unit is, I would like it to always have the bottom of it facing the center of the planet.

To do this I've tried using this:

transform.rotation = Quaternion.LookRotation(planet.position - transform.position);

This will face the object towards the center of the planet but not perpendicular. Also it will change the direction of the Y axis that the tank fires depending on the position it is on the planet.

How can I set the rotation of the tank so it is always having the bottom of it facing the center of the planet, and keep its current Y axis rotation?

  • \$\begingroup\$ I've answered this one a few times at this point, so I recommend making use of our search feature to find existing answers quickly, without the trouble of writing up a new question and waiting for replies. \$\endgroup\$ – DMGregory Dec 8 '19 at 16:03