Clickable area for attacking is huge even with a low value

Hi for some reason when putting my mouse near enemies the attack icon is shown and works even when the mouse is very far away from the enemy.

I’ve tried taking a screenshot but unfortunately, my mouse is never included in the screenshot.

It works fine for the pickups but with enemies, it doesn’t work correctly.

Here is my code:

RaycastHit[] RaycastAllSorted()
            RaycastHit[] hits = Physics.SphereCastAll(GetMouseRay(), _interactRaycastRadius);
            float[] distances = new float[hits.Length];

            for (int i = 0; i < hits.Length; i++)
                distances[i] = hits[i].distance;

            Array.Sort(distances, hits);
            return hits;

I’ve even tried setting the _interactRaycastRadius to as low as 0.05f and it doesn’t affect the clickable area when it comes to enemies in the slightest, but it does for the pickups.

Check the size of the colliders on your enemies. You can visualize each collider during Play mode by turning Gizmos on on the Game window, or putting the Scene view and Game View side by side when playing and seeing it in the Scene view.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.