[REQ] from a perpetual newbie ... move mouse, move object

Simple request … I want to move the mouse (up and down and left and right across the screen) and have an GameObject move with it.

The part I’m having trouble with is commented out.

var MoveMe : GameObject;
var MoveX : float;
var MoveY : float;

function Update ()
{
   MoveX = Input.GetAxisRaw("Horizontal");
   MoveY = Input.GetAxisRaw("Vertical");
   // transform MoveMe x = MX and z = MY;
}

Help on that last line appreciated.

This snippet should help:

function OnMouseDown () {
	var screenSpace = Camera.main.WorldToScreenPoint(transform.position);
	var offset = transform.position - Camera.main.ScreenToWorldPoint(Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z));
	while (Input.GetMouseButton(0))
	{
		var curScreenSpace = Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z);
		var curPosition = Camera.main.ScreenToWorldPoint(curScreenSpace) + offset;
		transform.position = curPosition;
		yield;
	}
}

If you stick that on an object in your world, it will get dragged around when you hold the mouse on it.

Cheers,
-Jon