How do I teleport an object and change its direction while keeping its velocity the same?

Here’s an illustration:

However, I do not want to make it always go exactly 90 degrees upwards. I just want to make sure that it goes in the direction of the portal (which in this case is upwards).

@droft1312 You can get object’s velocity vector, rotate it, and apply when you are changing object’s position. In this case:

Vector3 exitPortalPosition = new Vector3(5,-5,0);
float exitPortalRotation = 90f;

Rigidbody2D RB2D =  redCircle.GetComponent<Rigidbody2D>();
Vector2 velocity = RB2D.velocity;
velocity = Quaternion.Euler(0, 0, exitPortalRotation ) * velocity;
redCircle.transform.position = exitPortalPosition ;
RB2D.velocity = velocity;

More on vector rotation: Rotate a Vector3 direction - Questions & Answers - Unity Discussions