protected virtual void OnTriggerEnter2D(Collider2D collider) { // if the object that collides with the teleporter is on its ignore list, we do nothing and exit. if (_ignoreList.Contains(collider.transform)) { return; } if (collider.GetComponent <Character>() != null) { _player = collider.GetComponent <Character>(); _controller = collider.GetComponent <CorgiController>(); lucyHorizontalMovement = collider.GetComponent <LucyHorizontalMovement>(); } //if this teleporter is on top of the doorway, set a bool to true and set the player collider to the value that has collided with this trigger. if (TopSideTeleporter == true) { if (collider.GetComponent <Character>() != null) { StandingOnTopSide = true; _thePlayerCollider = collider; } } if (BottomSideTeleporter == true) { if (collider.GetComponent <Character>() != null) { EnteringUnderside = true; _thePlayerCollider = collider; } } }
/// <summary> /// Triggered when something enters the teleporter /// </summary> /// <param name="collider">Collider.</param> protected override void OnTriggerEnter2D(Collider2D collider) { // if the object that collides with the teleporter is on its ignore list, we do nothing and exit. if (_ignoreList.Contains(collider.transform)) { return; } //if the player is on the top side, set this to true StandingOnDoorTop |= TopSideTeleporter; if (collider.GetComponent <Character>() != null) { _player = collider.GetComponent <Character>(); _controller = collider.GetComponent <CorgiController>(); lucyHorizontalMovement = collider.GetComponent <LucyHorizontalMovement>(); } // if the teleporter is supposed to only affect the player (well, corgiControllers), we do nothing and exit if (OnlyAffectsPlayer || !AutoActivation) { base.OnTriggerEnter2D(collider); } else { if ((TopSideTeleporter == false) && (BottomSideTeleporter == false)) { Teleport(collider); } } }