I looked around and couldn’t find anything that seems to fix this, so apologies if I missed something.
I have two spherical bodies (let’s say Earth and the Moon); Earth has an axial tilt + rotation, Moon has an axial tilt and rotates around the earth. When the two of them are stationary in the worldspace, everything is fine.
Now I add movement through worldspace to the Earth; the Moon continues to rotate, but at the Earth’s original position, not its current position.
Here’s my code:
var Target:Transform;
var Speed:float = 0;
function Update()
{
if (Target)
{
if (Speed != 0)
transform.RotateAround(Target.position, transform.up, Time.deltaTime * Speed);
}
Am I doing something wrong? And/or how do I get the Moon to move with the Earth as the latter moves through worldspace?
Thanks!