- Home /
Multiple colliders close to each other overlapping UI
Hi guys.
So I have a question on whats the optimal way to achieve this behavior - I have multiple items close to each other, for example, a Lamp and a Desk drawer. When the Player's camera box collider hits one of the GameObjects ( Lamp / Desk ) colliders I show a Text in the middle of the screen, my issue is that the 2 objects are close to each other so my text overlaps. If i use a different text prefab then I'll still have 2 object texts shown which is confusing and the user will trigger their active animation together.
Any Idea whats the optimal way to handle this situation?
Answer by GottesSchaf · Jun 04, 2021 at 05:53 PM
Why don't you just use a Raycast in front of the camera to detect any given object? A Raycast can even have a certain distance so you can't interact with objects on the other side of your room. You can give a interactable object a tag like "interactable" and ask with the raycast hit info if it hits a object with the tag "interactable".
Thanks for taking the time to answer my question, I'll give Raycast a shot!
Your answer