EnergyPulsePower

using UnityEngine;
using System.Collections;

public class EnergyPulsePower : MonoBehaviour
{
  public float pulseDuration = 1f;
  
  public Transform goodOrb;
  
  void Update()
  {
    pulseDuration -= Time.deltaTime;
    
    if(pulseDuration <= 0)
      Destroy(gameObject);
  }
  
  void OnTriggerEnter(Collider other)
  {
    if(other.gameObject.tag == "BadOrb")
    {
      Instantiate(goodOrb, other.transform.position,           other.transform.rotation);
      GameObject.Find("GameManager).
        GetComponent<GameDate>().playerLives += 1;
      Destroy(other.gameObject);
      Destroy(gameObject);
    }
    else
      Destroy(gameObject);
  }
}

Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.