- Home /
Multiple technical questions/design question
How attach one sphere to another sphere on draging of sphere
hai friends.
Here i have so many spheres in bottom of screen, and i am trying to take them into middle of screen one by one. When i am dragging one sphere nearer to another sphere, this sphere should stick to that sphere automatically.
How to write script alt textplease help me. I am totally confused.
There are multiple problems here, and multiple different ways to solve them. Unity Answers is designed to answer single, specific issues. I suggest you break your problem down and do some research. I see three technical problem:
Drag and drop - questions with source have been posted a number of times. If you are going to use the Rigidbody component, take a look at the standard DragRigidbody.js script as a starting point.
The second problem is detecting when the two touch. If you are using the Rigidbody component, take a look at OnTriggerEnter(). If you are not going to use a Rigidbody, take a look at Vector3.Distance(), Physics.CheckSphere() and Physics.OverlapSphere().
From the graph, it looks like you want to build molecules. If so, then an sphere you've dragged needs to become a target. How you add this functionality will depend on how you solved the previous point.
Answer by YoungDeveloper · Dec 07, 2013 at 06:56 AM
You will need a Mouse grab (google it), if distance between those two objects is less than something, create a spring (or other) joint on the go, that part will connect to other.
Follow this Question
Related Questions
Question about tags and variables 0 Answers
Attach draggable sphere to camera when touched 0 Answers
Ways to make a ball delivery system, based on a back/down swing. 0 Answers
Best Placeholder gameObject? 1 Answer
Using Collider.OnCollisionEnter(Collision) without attaching the script to the concerned GameObject 2 Answers