using System.Collections; using System.Collections.Generic; using UnityEngine; public class Klahvid1 : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame Color[] toonid={Color.red, Color.green, Color.blue}; void Update() { float x=this.transform.position.x; float y=this.transform.position.y; float z=this.transform.position.z; if(Input.GetKeyDown(KeyCode.D)){ this.transform.position=new Vector3(x+0.1f, y, z); //Lisage klahvid ka vasakule, üles ja alla liikumiseks } if(Input.GetKeyDown(KeyCode.A)){ this.transform.position+=new Vector3(-0.1f, 0, 0); } if(Input.GetKeyDown(KeyCode.Mouse0)){ this.GetComponent().material.color=toonid[1]; RaycastHit hit; Ray kiir=Camera.main.ScreenPointToRay(Input.mousePosition); if(Physics.Raycast(kiir, out hit, 100)){ hit.collider.transform.position+=new Vector3(Random.Range(-1, 2), Random.Range(-1, 2), 0);//Hiirevajutus pöörab kujundit, muudab väiksemaks //ja kujund hüppab juhuslikku kohta hit.collider.transform.localScale*=0.9f; } } } }