protected override void Start() { base.Start(); possibleToFlyTo = new List <Vector3>(); if (FLIGHT_HEIGHT == 0) { Debug.LogError("FLIGHT_HEIGHT not set!"); } flyScript = GetComponentInChildren <FlyScript>(); }
void OnTriggerEnter2D(Collider2D otherCollider) { // Is this a shot? ShotScript shot = otherCollider.gameObject.GetComponent <ShotScript>(); FlyScript fly = otherCollider.gameObject.GetComponent <FlyScript> (); if (shot != null) { // Avoid friendly fire if (shot.isEnemyShot != isEnemy) { Damage(shot.damage); // Destroy the shot Destroy(shot.gameObject); // Remember to always target the game object, otherwise you will just remove the script } } if (fly != null) { Destroy(fly.gameObject); poops.poops++; } }
private void Awake() { if (!mController) { mController = GetComponent <MovementController>(); } if (!sController) { sController = GetComponent <SlideScript>(); } if (!cController) { cController = GetComponent <CrouchScript>(); } if (!gController) { gController = GetComponent <GlideScript>(); } if (!fController) { fController = GetComponent <FlyScript>(); } }
// Use this for initialization void Start() { fly = gameObject.GetComponent <FlyScript>(); }
// Use this for initialization void Start() { fly = gameObject.GetComponent<FlyScript>(); }