void SpawnPointObject( int pointObject )
{
int spawnlocindex = Mathf.RoundToInt( Random.value * 2f ); //Random int 0 to 3
GameObject obj = Instantiate( pointObjectPrefabs[pointObject], GetSpawnLocation(spawnlocindex), Quaternion.identity ) as GameObject;
obj.transform.SetParent( objectContainer );
Vector2 forceLoc = new Vector2();
switch( spawnlocindex ) //Get a position inbetween, based on where we started.
{
case 0:
forceLoc = Vector2.Lerp(throwTargets[0], throwTargets[1], Random.value);
break;
case 1:
forceLoc = Vector2.Lerp(throwTargets[2], throwTargets[3], Random.value);
break;
case 2:
forceLoc = Vector2.Lerp(throwTargets[4], throwTargets[5], Random.value);
break;
default:
Debug.LogError("WTF");
break;
}
Rigidbody2D rb = obj.GetComponent<Rigidbody2D>();
//Get the direction to the inbetween position and apply force to that location.
rb.AddForce( VectorExtras.Direction( VectorExtras.V2FromV3(GetSpawnLocation(spawnlocindex)), forceLoc ) * forceMultiplier );
rb.AddTorque( (Random.value - 0.5f) * 650f );
Destroy( obj, 10f );
}