private void launchPickUpInRandomDirection(CharacterPickUp characterPickupToLaunch) { Rigidbody2D rgb2d = characterPickupToLaunch.GetComponent <Rigidbody2D> (); Vector2 launchDirection = new Vector2(getXLaunchDirection(), getYLaunchDirection()); rgb2d.AddForce(launchDirection * launchSpeed); }
private void spawnNewPickUp() { int randomSpawnIndex = Random.Range(0, characterPickUpsToSpawn.Length); CharacterPickUp selectedCharacterPickUp = characterPickUpsToSpawn [randomSpawnIndex]; CharacterPickUp spawnedCharacterPickUp = Instantiate(selectedCharacterPickUp, transform.position, transform.rotation) as CharacterPickUp; spawnedCharacterPickUp.transform.parent = transform; launchPickUpInRandomDirection(spawnedCharacterPickUp); currentEllapsedTime = 0; }