Placing object in coordinates choosed by mouse

I really don’t know what is wrong. I want to do, that if player clicked anywhere, cube would move there.

using UnityEngine;
using System.Collections;

public class MyMoveObj : MonoBehaviour{
	public Camera camera1;

	void Update() {
            Vector3 p = camera1.ScreenToWorldPoint(
                  new Vector3(
                     Input.mousePosition.x, Input.mousePosition.y, 5f)
            Debug.Log("Pressed right click.");
            Debug.Log("Pressed middle click.");

I placed this code in GameObject (cube).
I think it should follow mouse while is clicked. Only X and Y coords should change and Z axis should be always at 5.
But when I click nothing happens.

is there a chance you just forgot to hook up camera1 ?

simply add some Debug.DrawLine calls and you’ll quickly find the problem

indeed just add Debug.Log(p) after line 12