Hello
I wonder if someone could point me to the right direction.
I have the following script, which I use to add objects as orbiting satellites for a host object:
using UnityEngine;
public class Satellite : MonoBehaviour
{
public GameObject host;
public float orbitSpeed = 5f;
public float radius = 0.1f;
private Vector3 center;
private float angle;
private void Start()
{
center = new Vector3(host.transform.position.x, host.transform.position.y, 0);
}
private void Update()
{
angle -= orbitSpeed / radius * Time.deltaTime;
var offset = new Vector3(Mathf.Sin(angle) * radius, Mathf.Cos(angle) * radius, 0);
transform.position = center + offset;
}
}
Now when I create these object, I randomize the radius and it works fine. However, their initial positions are always like this:
How could I set their initial position to be something else? Any help would be appreciated.
- Barra