Colliders vs RayCast
I have to implements automatic crosshair aiming in my FPS game. What is the best (performing on iPhone) solution for that?
I can see two options here:
1: Using Triggers:
Ex: Adding an additional collider to the player object in shape of a long stick, potentially long sphere) and a rigid body marked as kinematic Detecting OnTriggerEnter/Exit between player and enemy colliders. After that use a linecast and if there are no objects on the way moving crosshair based on enemy position.
2: Using RayCasting:
Ex. Use couple (at least three) raycasts in a direction coming from camera, detect object on their way using Physics.Raycast Once enemy has been detected move crosshair based on its position.
So, what is the most expensive operation? Using rigidbody with OnTriggerEnter/Leave handling with one LineCast or 3 raycasts (with additional layer)?
Thanks