There is a cube with a boxing collider. When this cube moves, it passes through walls (which also have a boxing collider). Cube code
public class RocketMovement : MonoBehaviour { public float speed = 3.0f; private float deltaX; private float deltaZ; private Component collider; // Use this for initialization void Start() { collider = this.GetComponent<BoxCollider>(); } // Update is called once per frame void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); this.transform.position = new Vector3(ray.GetPoint(10f).x, this.transform.position.y, ray.GetPoint(10f).z); } }