Moving selected unit to location in space rts based on screen touch

I have a space rts game im making, and i have my code set up for my ships to move to locations, but i cannot accurately get the location in world space based on touch. I can rotate my camera around in 3d space, but i want to be able to move ships like “sins of the solar empire”.

If my camera is on the side of my ship and if i touch in front i want the target position to be forward in front of it and up / below it.
If my camera is above i want it to move my ship on that axis (not vertically) and just move it like im looking down upon it like command and conquer style.

How would i get this effect and still be able to rotate my camera freely? (and accomodate for my camera being at uneven rotations)

I assumed i could have 3 grids that for the 3 axis i would move on, and just raycast to these grids’ colliders and get the points that wya, but that seems inefficient, as i eventually want to generate random maps.

This shows the 3 grids i meant and each is invisible and meant to detect each touch’s raycast to determine location to move the ship:

How would i go about doing this?
By the way this is for an android 3.2 tegra 2 10.1 tablet specs.

I hope i explained this enough, if not just ask to clerify or a find a video on youtube.

So did I understand you correctly, you want your ship to move on a plane which is orthogonal to the viewing direction?

If this is what you want you could setup an invisible plane which goes through your ships position and rotates with the camera. You can then do a ray cast with this plane in order to determine the ship’s new position.

If you do the plane in geometry in unity, you can use the unity raycasting functionality. Otherwise, you could do the collision calclulation yourself. (collision of ray with plane)

Your cameras view matrix takes the ships 3D position and translates it to the screens X, Y (&Z) to render it. If you do the reverse to the click position (and add the ships distance from the camera as the Z) then it should return a 3D point in the plane of travel you are after.

What do u mean by reverse? How would I go about that, in code? If I use the X and y from the touch position then the position will be off if I just use the distance from camera to ship as z component. Wouldn’t this coordinate also be in local position referenced from the camera? How would I get this as a real world position relative to the world origin then?