(2D) How do i create a smooth movement transition from a point to another point on an orbit?

Edit: Refined question at end.

I have an enemy that spawns at the edge of my screen and makes it way in the direction of the player. Once it reaches a certain distance from the player it will begin an orbit around them.

Any suggestions on how I can make the transition from “approaching player” to “orbiting player” smooth? I’ll see if I can illustrate what I mean:

Ideally the steps would go something like this:

  1. Enemy spawns

  2. Set distance from player

  3. Approach this distance

  4. Set point in orbit (potentially this should be a set distance away from where the ‘approach’ ends)

  5. Begin smooth transition to this point.

  6. Once point is reached, begin orbit.

Currently the enemy will hit the orbit range and begin orbiting straight away, making it look like it hits an “invisible wall” briefly.

My thoughts are I could use something like a Bezier curve for the smooth transition, but I’m not sure how to go about getting a point on the orbit to set as an end point for the curve.

This is the code i’m currently using to orbit once the enemy reaches a certain distance from the player:

transform.RotateAround(target.transform.position, new Vector3(0,0,1), (orbitSpeed * Time.deltaTime));

Additionally, this is all in 2D.

Hope that’s enough information, I don’t necessarily need code, but more ideas on how this can be done: anything is greatly appreciated!

Edit: I’ve solved the issue of getting a point on a circle. Specifically, I divided by circle into quadrants to get a random point along the circle in a certain quadrant.

if(quadrant == 1)
{
    angle = Random.Range (90, 180);
}
else if(quadrant == 2)
{	
    angle = Random.Range(0, 90);
}
else if(quadrant == 3)
{
    angle = Random.Range(180,270);
}
else
{
    angle = Random.Range(270, 360);
}

Vector3 circ = new Vector3(Mathf.Cos (angle*Mathf.Deg2Rad), Mathf.Sin (angle*Mathf.Deg2Rad), 0);

orbitPoint = target.transform.TransformPoint (circ * radius);

My question now is: With a starting position vector and a distance, how can i get a point where the start position + distance would intersect with a point on the circle? Illustration:

![46036-circlepoints.png|483x411](upload://zNv9vw0XBN6cXzo4GTiHNirch9C.png)

If you already have your orbiting code working the way you want, you can do this to remove the “invisible wall” problem. These steps assume a correct distance from player of 10 units (substitute your own number) and that you are setting the velocity of your object:

  1. begin your orbiting code when the object is not quite in range of the player, say 11 units away

  2. Once the object is within some distance (again, we’ll say 11 units), modify its velocity each FixedUpdate to be (I am assuming a normal speed of 1 unit a second):

    1.0f * (distanceToPlayer - 10.0f); //change the 10 to be what your distance should be

  3. Now, as the object transitions from 11 units to 10 units away, it will slow down while the orbit code kicks in. That will give it a nice smooth transition.