using System.Collections; using System.Collections.Generic; using UnityEngine; public class Liikumine : MonoBehaviour { float kx = 3; float samm = 0.1f; float nurk = 90; float nurgasamm = 5; void Start () { Debug.Log("algus"); } void Update () { kx += samm; this.transform.position = new Vector3(kx, 0, 0); if (Input.GetKeyDown(KeyCode.S)) { this.transform.localScale += new Vector3(0.1f, 0.1f, 0.1f); } if (Input.GetKeyDown(KeyCode.P)) { nurk += nurgasamm; this.transform.rotation = Quaternion.Euler(new Vector3(0, 1, 0) * nurk); } if (Input.GetKeyDown(KeyCode.Mouse0)) { Ray kiir = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(kiir, out hit, 100)) { hit.collider.GetComponent().material.color = Color.blue; } } } private void OnCollisionEnter(Collision collision) { Debug.Log(collision.gameObject.name); if (collision.gameObject.name == "otsakuup") { if (samm > 0) { samm = -samm; GetComponent().material.color = Color.yellow; collision.gameObject.GetComponent().material.color = Color.black; } } //Põrka tagasi ka alguskuubist, muuda ka siis värvi } }