how to move an object clone to mouse position, i dont understand ?

var shine : GameObject;
var clone : GameObject;
var move : Transform = float (1,0,1);
function Start () {

}

function Update () {

//if(Input.GetMouseButtonDown(0))

//{

//Invoke ("Spawn", Random.Range( 0, 1));

//Destroy(GameObject.Find("Shine(Clone)"), 3);

//}
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);

if (Physics.Raycast (ray, 100)) {
	Debug.Log("Pressed left click.");
Instantiate (shine, Input.mousePosition,Quaternion.identity);
	print ("Hit something");

}

if(Input.GetMouseButtonDown (0))
move.shine.Vector3(camera.nearClipPlane = 0.1);
Destroy(GameObject.Find("Shine(Clone)"), 3);

if(Input.GetMouseButtonDown(1))
{
Debug.Log(“Pressed right click.”);
}
if(Input.GetMouseButtonDown(2))
{
Debug.Log(“Pressed middle click.”);
}

}

Hi Ahaley, Here some steps please follow these steps

  • First at run time you need to find out the Object Clone by GetComponent or by tag or GameObject.Find(“a(Clone)”).

  • now in Update() find the Current mouse Position.

  • Now your Clone.transform.position = Vector3.MoveTowards(Clone.transform.position , mouse.transform.position , speed * Time.deltaTime );

    Hopefully it will work fine.