public void onPickUpPowerup(BasePowerup pow) { if (pow) { GetComponent <AudioSource>().PlayOneShot(pow.pickupAC); } }
void handleMagnet() { m_powerups = (BasePowerup[])GameObject.FindObjectsOfType(typeof(BasePowerup)); for (int i = 0; i < m_powerups.Length; i++) { BasePowerup pow = m_powerups[i]; if (pow) { Vector3 vec = transform.position - pow.transform.position; float d0 = vec.magnitude; // Debug.Log ("Distance" + d0); if (d0 < distance && pow.isMagnatized) { pow.GetComponent <Rigidbody>().velocity += vec.normalized * moveSpeed; } } } }