private RacerHealthClass theRacer; // Used to access variables on a racer. #endregion Fields #region Methods //OnTriggerEnter //Purpose: detects when the projectile hits an object with the tag "Racer," the projectile will get the health variable // from the object and call the DealDamage function then destroy itself. //Parameters: Collider other //Returns: void void OnTriggerEnter(Collider other) { if(other.gameObject.tag == "Weapon"){ Physics.IgnoreCollision(this.collider, other); } if(other.gameObject.tag == "Racer"){ theRacer = other.gameObject.GetComponent<RacerHealthClass>(); theRacer.Health -= DealDamage(theRacer.Armor); GameObject spawnedHitParticle = Instantiate(HitParticle, this.transform.position, this.transform.rotation) as GameObject; // gameObject.transform.position = StartPosition.position; gameObject.SetActive(false); } }
private RacerHealthClass theRacer; // Used to access variables on a racer. #endregion Fields #region Methods //OnTriggerEnter //Purpose: detects when the projectile hits an object with the tag "Racer," the projectile will get the health variable // from the object and call the DealDamage function then destroy itself. //Parameters: Collider other //Returns: void void OnTriggerEnter(Collider other) { // if(other.gameObject.tag == "Weapon"){ // Physics.IgnoreCollision(this.collider, other); // } if(other.gameObject.tag == "Racer"){ Debug.Log("Hit Racer"); theRacer = other.gameObject.GetComponent<RacerHealthClass>(); theRacer.Health -= DealDamage(theRacer.Armor); GameObject spawnedHitParticle = Instantiate(HitParticle, this.transform.position, this.transform.rotation) as GameObject; Destroy(gameObject); } else { GameObject spawnedHitParticle = Instantiate(HitParticle, this.transform.position, this.transform.rotation) as GameObject; Destroy(gameObject); } }
//OnTriggerEnter //Purpose: detects when the projectile hits an object with the tag "Racer," the projectile will get the health variable // from the object and call the DealDamage function then destroy itself. //Parameters: Collider other //Returns: void void OnTriggerEnter(Collider other) { // if(other.gameObject.tag == "Weapon"){ // Physics.IgnoreCollision(this.collider, other); // } // if(other.gameObject.tag == "Racer"){ // Debug.Log("Hit Racer"); // theRacer = other.gameObject.GetComponent<RacerHealthClass>(); // theRacer.Health -= DealDamage(theRacer.Armor); // Destroy(gameObject); // } string theTag = other.gameObject.tag.ToString(); switch(theTag) { case "Weapon": Physics.IgnoreCollision(this.collider, other); break; case "Racer": Debug.Log("Hit Racer"); theRacer = other.gameObject.GetComponent<RacerHealthClass>(); theRacer.Health -= DealDamage(theRacer.Armor); Destroy(gameObject); break; } }
// Use this for initialization void Start() { MotionStart(); racer = this.GetComponent<RacerHealthClass>(); // MotionStart(); }
public static void AddRacer(RacerHealthClass racer) { if(!targets.Contains(racer.transform)){ targets.Add(racer.transform); } }