Allow input when aiming over object

Hi all, i’m relatively new to scripting, so please bare with me. What i’m trying to do is create a script that will allow me to have an aiming reticle move around the game area freely, and when the reticle is over an object (either a red, blue green or yellow object) the player will be able to press the corresponding key (1=red 2=blue 3=green 4=yellow)to highlight the target, but if the reticle is not over the corectly colored target then the key does nothing. As i said, i’m new to this, coming from an art background, so i’m not quite sure what the best way to get started is.

As it is now i have my aiming reticle as a simple 3d plane facing the camera that moves in the play area with the mouse, but i’m not quite sure if this is even the appropriate way of implementing my aiming system.

Any help would be much appreciated, there’s a lot to absorb on this side of the development scene. Thanks.

You need to put a collider on the colored objects, give them an appropriate tag that indicates their color, perform a ray cast from your camera, check the object that the ray cast may hit (look at the tag value), and then set a flag in the script that is capturing your keyboard input.