- Home /
How to detect an object that comes in the "Crosshair" field of view?
I'm making an auto turret firing game. It will detect the enemy object seen in the field of crosshair image that I'm using. And it will start firing when the object aligns with the midpoint of the crosshair. Right now I've made shooting possible when the enemy objects aligns through the midpoint of crosshair from any distance. But I'm unable to detect any object coming in the field of crosshair. For shooting I'm using raycast but for detection I've tried all method like colliders triggers and raycast. The problem is it will not exactly detect an enemy object, seen or coming in the field of crosshair view. ![alt text][1] ![alt text][2]
Answer by toficofi · Mar 20, 2021 at 03:26 AM
How about using Physics.OverlapBox
extending from the crosshair to broadly check "is there something within the broad area of the crosshair", and if that's the case, then using Physics.OverlapSphere
at the intersection position to check if the object is touching exactly the circle of the crosshair?
Your answer
Follow this Question
Related Questions
Detection Perimiter 3 Answers
Raycasting help 2 Answers
Get closest point on collider on at a certain z depth 0 Answers