# Moving 2 objects with this script... easy, right?

**URL:** https://discussions.unity.com/t/moving-2-objects-with-this-script-easy-right/398879
**Category:** Scripting
**Tags:** Scripting
**Created:** [September 29, 2009, 9:13pm UTC](https://discussions.unity.com/t/moving-2-objects-with-this-script-easy-right/398879 "2009-09-29T21:13:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Holocene](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/holocene/32/262748_2.png) [@Holocene](https://discussions.unity.com/u/Holocene)
#### Post date: [September 29, 2009, 9:13pm UTC](https://discussions.unity.com/t/moving-2-objects-with-this-script-easy-right/398879/1 "2009-09-29T21:13:41Z")

</div>

Hi, all,  
I’m using the following code to move a 2D object.  
It works well, but I would like to modify this script to enable two objects to be dragged independently.

Any ideas?

Thanks,

Greg

```auto
var object : GameObject;
var speed = 5.0;
var swipeVector = Vector2.zero;

function Update () {
  if(iPhoneInput.touchCount > 1) {
    var touch = iPhoneInput.GetTouch(1);
    swipeVector = touch.positionDelta * Time.deltaTime * speed;
    object.transform.position += swipeVector;
  }
transform.position.x = Mathf.Clamp(transform.position.x, -5, 5.2);
transform.position.y = Mathf.Clamp(transform.position.y, -1, 4.5);
}

```

---

<div class="post-metadata">

### Author: ![anon\_85768832](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@anon\_85768832](https://discussions.unity.com/u/anon_85768832)
#### Post date: [September 29, 2009, 9:37pm UTC](https://discussions.unity.com/t/moving-2-objects-with-this-script-easy-right/398879/2 "2009-09-29T21:37:26Z")

</div>

Why are you reposting the exact same question you already have posted before? Also, why aren’t you posting these iPhone specific questions in iPhone Development?

🙂

[http://forum.unity3d.com/viewtopic.php?t=33047](http://forum.unity3d.com/viewtopic.php?t=33047)

FYI: I’m locking this thread, all replies and follow-up should be done in the above thread (t=33047).
