Detect collision with x and y co-ordinates of touch/swipe and click/drag
Hi all, I'm a newbie to unity (javascript background) - I've been looking for something that is suitable for my needs but having difficulty finding an answer. I have about 70 balls bouncing around the screen and I need to be able to efficiently and quickly check when they collide into an x and y co-ordinate of the current input position - so a user could have their finger on the screen and swiping and the collisions are detected.
The balls have Circle Collider 2D and RigidBody 2D components.
The balls do not interact with each other, so they overlap - so if a user clicks the intersection of n balls, they all would need to detect the click/touch - of which I can then code some resulting logic, including knowing how many balls were involved in that input collision.
I tried some tests with mouseover by adding this to the prefab ball script:
function OnMouseOver()
{
Destroy (gameObject, 1.0);
}
But that took a second or so after the mouseover to respond...I must be doing something quite wrong! How can I get a quick snappy responsive setup to achieve this? huge thanks.
Answer by aceofpack · Jan 14, 2016 at 09:55 PM
Ok, I've been an idiot and realised the 1.0 is the delay until destroy! The question with the overlaps still is valid
Your answer
Follow this Question
Related Questions
Physics 2D with tile collider corner problem 2 Answers
Executing a function upon 2d collision 1 Answer
C# - My increament code is not working? 1 Answer
Prevent "useless" character movements 0 Answers
Collisions not working in top-down RPG? 0 Answers