I have two ships in UNITY, let's call them A and B:
Ship A moves steadily forward.
Ship B has to chase ship A, approaching it and rotating around it but at a certain distance.
The basic skeleton of the operation is the following:
private void()
{
Move();
Turn();
}
For B to chase A I use this code:
private void Move()
{
transform.position += transform.forward * movementSpeed * Time.deltaTime + target.transform.position;
}
That is in a method called Move which I invoke in Update. I also have another method called Turn that handles rotations:
private void Turn()
{
Vector3 pos = target.transform.position - transform.position;
Quaternion rotation = Quaternion.LookRotation(pos);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, rotationalDamp * Time.deltaTime);
}
How can I do, so that from a certain distance, ship B did not get closer to ship A and keep rotating (like orbiting) around her?
Thank you very much!