How to select particular game objects and snap them to other objects?
Okay, so I am trying to make a simple towers of hanoi game in Unity 5. So far I have created the towers and labelled them as tower 1, tower 2, and tower 3. I have also made the three rings, TinyRing, MediumRing, BigRing.
I wrote a c# script which allows me to move the rings, but since i have no idea how to select objects individually, all three rings move at once. Is there a way to select particular rings so that i can assign a hotkey for each ring?
Also, i want to snap these rings on the towers when they collide with the tower. But this should be done in such a way that if there is already a ring existing on the tower, it will either place it on top of the bigger ring/would not allow me to place it on the smaller ring. Any advice on how to go about this would be much appreciated.
Here's my code so far for the movement of the rings.
public class Control : MonoBehaviour
{ public float speed = 3.0f;
void Update ()
{
if (Input.GetKey (KeyCode.LeftArrow)) {
transform.position += Vector3.left * speed * Time.deltaTime;
}
if (Input.GetKey (KeyCode.RightArrow)) {
transform.position += Vector3.right * speed * Time.deltaTime;
}
if (Input.GetKey (KeyCode.UpArrow)) {
transform.position += Vector3.up * speed * Time.deltaTime;
}
if (Input.GetKey (KeyCode.DownArrow)) {
transform.position += Vector3.down * speed * Time.deltaTime;
}
}
}