I'm trying to move and rotate some clouds around a target planet (which is just a circle at the moment). I got the movement down, but I am really struggling with the rotation part. I want it to rotate in proportion to where it is on the circle but I'm stuck trying to guesstimate the right numbers. Here is the code:
public class CloudMovement : MonoBehaviour
{
public GameObject target;
private float RotateSpeed = .05f;
private float Radius = 1.0f;
private Vector2 center;
private float angle;
private void Start()
{
center = target.transform.localPosition;
Radius = target.transform.localScale.x / 1.5f;
}
private void Update()
{
angle = angle + RotateSpeed * Time.deltaTime;
this.transform.Rotate (Vector3.forward * -angle * Time.deltaTime);
Vector2 offset = new Vector2(Mathf.Sin(angle), Mathf.Cos(angle)) * Radius;
this.transform.position = center + offset;
}
}