using System.Collections; using System.Collections.Generic; using UnityEngine; public class cs03 : MonoBehaviour { // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray1 = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit1; if (Physics.Raycast(ray1, out hit1) == true) { //Debug.Log(hit1.collider.name); if(hit1.collider.name =="Cube") { this.gameObject.transform.Translate(0, 0.2f, 0); } } } } }