Issues with 2d movement

Two object, call them “red” and “blue”. The aim is if I click “blue”, the “red” moves exactly same position. Right now this move happens instantly, but would like to set the speed to see “red” moving. This is the script attached to “blue”. Any help is appreciated.

using UnityEngine;
using System.Collections;

public class ClickCheck : MonoBehaviour {

public float speed = 1.5f;
private Vector3 target;

void OnMouseUp()
	target = Camera.main.ScreenToWorldPoint(transform.position);
	target.z = transform.position.z;
	GameObject.Find("red").transform.position = Vector3.MoveTowards(transform.position, target, speed * Time.deltaTime);


Your object “Red” is forced to move only once, when you release the mouse button. Do that the OnMouseUp would set a boolean to true, and move in update function.

Well… cant get this to work. Shortest code (attached to “blue”) to move “red” instantly is here… whats the best way to modify this, so I can see the “red” actually moving?

public var check : boolean;

check = false;

var red = GameObject.Find(“red”);

function OnMouseOver ()
{if (Input.GetMouseButtonUp(0)) {
check = true;

if(check) {
    red.transform.position = transform.position;
    check = false;