private void OnTriggerEnter(Collider other) { if (other.CompareTag("Powerup")){ Destroy(other.gameObject); isPoweredUp = true; powerupIndicator.SetActive(true); StartCoroutine(PowerupCountdownRoutine()); } } private void OnCollisionEnter(Collision other) { if (other.gameObject.CompareTag("Enemy") && isPoweredUp){ Rigidbody enemyRB = other.gameObject.GetComponent<Rigidbody>(); Vector3 awayFromPlayer = (other.gameObject.transform.position - transform.position); enemyRB.AddForce(awayFromPlayer * powerupStrength, ForceMode.Impulse); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter