IEnumerator FlyBeforeDestroy() { float waitTime = 0.2f; switch (direction) { case Direction.North: waitTime = 0.3f; break; case Direction.South: waitTime = 0.26f; break; case Direction.West: waitTime = 0.22f; break; case Direction.East: waitTime = 0.22f; break; } yield return(new WaitForSeconds(waitTime)); _worldEntity.DeregisterMe(); _worldTrigger.DeregisterMe(); Destroy(gameObject); }
void Update() { if (IsVisible) { _worldEntity.RegisterMe(); _visuals.SetActive(true); _xyVisuals.SetActive(false); _zyVisuals.SetActive(false); Vector3 v = new Vector3(_xyComponent.VisualPos[0], _xyComponent.VisualPos[1], _zyComponent.VisualPos[0]); _visualsTransform.position = v; } else { _worldEntity.DeregisterMe(); _visuals.SetActive(false); _xyVisuals.SetActive(true); _zyVisuals.SetActive(true); } }