When object1 hits object2 reset object1?

I have a ball and say if it rolls on to an object (object 2), I want the ball (Object 1) to reset to were it started? How would this be done? Thanks :slight_smile:

function OnCollisionEnter(hit:Collision)
{
    if(hit.collider.gameObject.name == "Object2")
        transform.position = Vector3(x, y, z);
}

use this as the collision for Object1 and make sure the name of the object you want to check collision with is Object2.
modify x y and z values in the Vector3 → () to the position in which you want it to respawn to.

Both need rigidbodies for this to work.

var object1 : GameObject;
var startLocation : Vector3;

function OnCollisionEnter(col : collision)
{
	//if(col.gameObject.tag == "ResetBallWhenHit")  <-- alternative to the line below
	if(col.gameObject.name == "Object2")
	{
		Instantiate(object1, startLocation, object1.rotation);
		Destroy(gameObject);
	}
}

Note: untested

Doh, posted at the same time. The solution amit1532 did is better :slight_smile:

Got it working Thanks* <3