So, I have this code that works to make objects rotate around the player, but the orbit is influenced by the player movement (gif explain better than words). How to make the objects keep rotating regardless on how the player is moving?
public class orbitController : MonoBehaviour
{
GameObject cube;
public Transform center;
public Vector3 axis = Vector3.up;
public Vector3 desiredPosition;
public float radius;
public float radiusSpeed = 0.5f;
public float rotationSpeed = 80.0f;
void Start () {
cube = GameObject.FindWithTag("Player");
center = cube.transform;
transform.position = (transform.position - center.position).normalized * radius + center.position;
}
void Update () {
transform.RotateAround (center.position, axis, rotationSpeed * Time.deltaTime);
desiredPosition = (transform.position - center.position).normalized * radius + center.position;
transform.position = Vector3.MoveTowards(transform.position, desiredPosition, radiusSpeed);
}
}