using System.Collections; using System.Collections.Generic; using UnityEngine; public class liiguparemale : MonoBehaviour { public float kiirus = -0.1f; float samm; void Start () { samm = kiirus; Debug.Log("algus"); } private void OnCollisionEnter(Collision collision) { Debug.Log(collision.gameObject.name); if (collision.gameObject.name == "otsakuup") { samm = -kiirus; this.GetComponent().material.color = Color.green; } if (collision.gameObject.name == "alguskuup") { samm = kiirus; this.GetComponent().material.color = Color.red; } } void Update () { transform.position = new Vector3(transform.position.x + samm, transform.position.y, transform.position.z); if (Input.GetKeyDown(KeyCode.A)){ this.GetComponent().material.color = Color.yellow; GameObject.Find("alguskuup"). GetComponent().material.color = Color.yellow; } 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; } } } }