using System.Collections; using System.Collections.Generic; using UnityEngine; public class JuureKood : MonoBehaviour { // Start is called before the first frame update void Start() { GameObject kuup1=GameObject.CreatePrimitive(PrimitiveType.Cube); kuup1.transform.position=new Vector3(2, 0, 0); kuup1.name="esimene"; Debug.Log(kuup1.name); GameObject kuup2=GameObject.CreatePrimitive(PrimitiveType.Cube); kuup2.transform.position=new Vector3(-2, 0, 0); kuup2.name="teine"; Debug.Log(kuup2.name); } void Update() { if(Input.GetMouseButtonDown(0)){ Ray kiir=Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit tabamus; if(Physics.Raycast(kiir, out tabamus, 100)){ Debug.Log(tabamus.transform.gameObject.name); //Liiguta vajutatud kuubikut paremale tabamus.transform.position+=new Vector3(1, 0, 0); } } } }