Depending on what you’re trying to do, you might wanna put your own collider on it and do your own raycast check from the camera touch ray. You can actually ask for a specific collider, “Does this ray hit this collider?”
Here’s some more scribbled notes and links about this stuff:
Raycasting, colliders, planes, Plane, etc:
There are many types of 3D raycasts.
One is the generic Physics one: hits anything in the scene
Another is one that lives on a collider.
If you know which collider you care about, you can use that collider instance to see if a ray hits it.
That way you not only know that it hit, but because you are already asking "Did anything hit this collider?" you also know what collider it is.
These are some of the types of 3D raycasts:
https://docs.unity3d.com/ScriptReference/Physics.Raycast.htm…
You can get rays from the camera at a given spot, so one approach is to cast rays from the camera corners and make sure they hit your terrain, or hit your terrain bounding box.
To ignore screen pixel dimensions and just get the corner rays, this is the API you want:
The nice part is that it doesn’t matter how your camera is set, how your field of view is set, etc., It just works.
You can use this to raycast and hit physics on your ground using:
asks “did I hit any collider in the scene?…
And there is also EventSystem.RaycastAll for raycasting in the UI / EventSystems context.
Raycasting in 2D:
Epoch! I always love your posts because you’re always working on the next thing. Awesome.
So for this I would pick a random spot from left to right at the top of your screen, then raycast down to “hit” the terrain and see how high it is at that point, and from that you can emplace your missile above the ground, or on a pedestal or whatever.
Remember there are various flavors of Raycast in Physics2D:
https://docs.unity3d.com/ScriptReference/Physics2D.Raycast.html
“Tell me if I hit any 2D col…