RTS Style pointer with multiple Collider 2D

Hello there!

As of now, I can’t find a way of selecting a ingle unit in my rts styled game precisly.

The thing is, all units have there normal non-trigger colliders for close combat, and, in a child object, an trigger collider to detect if enemies are in range for, well… ranged combat.

Alas, I just can’t get the mouse to ignore the triggercollider, even so I only want to select a unit if I hit the close combat collider (borders of the associated sprite).
Be it with RayCast2D or with on MouseOver, whatever I do, I just cant get the Engine to seperate the TriggerCollider and the normal one.

Any ideas, anyone?

`We rock!
Max

If it would work out in your design, I recommend putting the long-range and short-range colliders on separate layers. Only one would need to be on a different layer.

At that point, you should be able to use a RayCast2D:

"public static RaycastHit2D Raycast(Vector2 origin, Vector2 direction, float distance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, float minDepth = -Mathf.Infinity, float maxDepth = Mathf.Infinity); "

and

“This function returns a RaycastHit object with a reference to the collider that is hit by the ray (the collider property of the result will be NULL if nothing was hit). The layerMask can be used to detect objects selectively only on certain layers (this allows you to apply the detection only to enemy characters, for example).