Moving Object to mouse

I am making a space flying game and I have the spaceship rotate towards an empty object in front of it. What I want is to move the mouse, and have the ship rotate towards that place. My idea was to have an empty object out infront of the ship, and it the empty object moves in the x and y plane to where the mouse is ( the object will be fixed to camera so it will move with the player).

So my question is how do i move this empty object to the x and y coordinates of the mouse? I am rather new to scripting

You don’t necessarily need to use a separate game object for this.

An easy solution would be to build a ray through the mouse position (using Camera.ScreenPointToRay()), and then intersect this ray with the xy plane. You can then orient the ship towards the intersection point using the method of your choice.

Im sorry, I forgot to mention this was a 3d space flying game. I want the player to fly in the z direction, and when the mouse moves say diagonally to the top right, I want the ship to angle itself to the top right, in 3d space.

and the mouse is not going to be centered.

Ah I see. Okay I have a raycast that will work. What i did was make a plan in front of the player, shoot a raycast from camera to the mouse, and where it hits the plan, rotate the player to face it.

now im having trouble scripting how to save the hit location, and then rotate the player to face it. lol