3D FPS Aiming with Touch Controls

Hi,

I’ve started working on the prototype of my first (original) unity game. I’ve done a few tutorials, and have a simple game set up that lets the player shoot moving targets.

Now I want that to work on Android. I’ve watched/read some tutorials on touch controls, and they all tell me to use raycasts to figure out if my touch is hitting something - but I don’t want to only know if i’ve hit something, but also if i’ve missed something.

My first thought was to have a plane slightly larger than the physical screen at some distance from the camera, then I can raycast on its layer to get a hit point, which the bullet then flies towards.

But, I really don’t know if that’s an optimal solution or not. I’m sure that this is a problem that has been solved before, even if I couldn’t find it on the answers boards.

Thanks in advance,
Adam

If you want to know when you didn’t hit something, just check when you raycast returns false!

Pseudo code:

if(someTouchOccured){
	if(yourRaycast){
		//We clicked and hit something
		if(hit.tag is a target tag){
			//we hit the target
		}else{
			//our ray hit something other than the target
		}
	}else{
		//We clicked and didn't hit anything
	}
}