How to not teleport into Game Objects c#

Hello, I am currently working on a game where the Player has the ability to teleport as shown below:

 void Teleport(Transform teleport_transform)
    Vector3 new_pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);      
    new_pos.z = teleport_transform.position.z;                                
    teleport_transform.position = new_pos;

I was wondering, since I have game objects in my scene and the player can essentially teleport into them and get stuck if there was a simple way of negating it or pushing them out of the object?

Thanks for the help!

You could perform a SphereCast at the position you intend to teleport to. Then if it hits something, move the player the hit distance and hit normal.

You can read up more here: SphereCast

But that’s what I would try.