I am Making Bubble Shotter game in which bubbles get blast when 3 same colors get to gather . How can i detect neighbouring objects?
DO i need to raycast in all direction to get all information about neigbours or CircleCast will do that thing? The game is in 2D
Answer by grimmdeveloper · Jun 18, 2016 at 08:42 AM
If you store your objects first in an array, you can use a foreach on that array of objects calculating distance using Vector3 distance and the closest objects would obviously be the neighbors. You could also just using something simple such as OnCollisionStay or in 2d it would be OnCollisionStay2D. https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionStay.html https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionStay2D.html
Your answer
Follow this Question
Related Questions
I think my raycast detects destroyed gameobjects 0 Answers
Physics2D.Raycast producing bizarre results. 0 Answers
Raycast2D is hitting itself even when set to ignore own collider 5 Answers
RaycastAll from prefab is not picking up a collider from another prefab 1 Answer
Raycast2D Two Objects at the same time 2 Answers