#pragma strict

var isMoving : boolean;
function Start () {

gameObject.rigidbody2D.mass=Random.Range(100,1000);
gameObject.rigidbody2D.AddForce(10*Vector2(Random.Range(-1001,1000),Random.Range(-501,500)));

}

function Update () {


}

function OnCollisionEnter2D (hit : Collision2D){
	yield;
	if(hit.gameObject.layer!=8){
		Destroy(hit.gameObject);
		gameObject.Find("ControllerManager").GetComponent(js_assignctrl).numberOfPlayers--;
	}else{
		hit.gameObject.rigidbody2D.AddForce(200*Vector2((hit.gameObject.transform.position.x- transform.position.x),(hit.gameObject.transform.position.y- transform.position.y)).normalized);
	}
}

function OnTriggerStay2D (other : Collider2D){
if(other!=null){
	var distance : float;
	distance = Vector2.Distance(other.transform.position, transform.position);	
	other.attachedRigidbody.AddForce( (10/Mathf.Sqrt(distance)) * Vector2((transform.position.x- other.transform.position.x),(transform.position.y- other.transform.position.y)).normalized);
}else{

}
}

