private void CollidedWithPickUp(Collision other) { APickup pickup; // Find the Obstacle component on the other object (should have one if it has the tag "Obstacle"). try { pickup = other.gameObject.GetComponent <APickup>(); } catch (Exception) { throw new Exception("Error in method " + ExceptionUtils.GetCurrentMethod() + " of " + ExceptionUtils.GetCurrentClass(this) + ": Failed to find an APickup Script on the game object - " + ExceptionUtils.GetCurrentClass(other.gameObject)); } // We have, raise an event for anyone listening! OnCollectedPickup(pickup.type); // Now deal with the collision. pickup.Collect(); }
private void CollidedWithObstacle(Collision other) { Obstacle obs; // Find the Obstacle component on the other object (should have one if it has the tag "Obstacle"). try { obs = other.gameObject.GetComponent <Obstacle>(); } catch (Exception) { throw new Exception("Error in method " + ExceptionUtils.GetCurrentMethod() + " of " + ExceptionUtils.GetCurrentClass(this) + ": Failed to find an Obstacle Script on the game object - " + ExceptionUtils.GetCurrentClass(other.gameObject)); } // We have, raise an event for anyone listening! Debug.Log("CollidedWithObstacle - Not implemented yet..."); // Now deal with the collision. if (!godMode) { if (obs.killOnCollide) { TakeDamage(HP.Remaining, obs); } else { TakeDamage(obs.damage, obs); } } }