Esempio n. 1
0
 private void CheckBorders()
 {
     if (!GameAreaHelper.IsInGameplayArea(transform, _representation.bounds, Camera.main))
     {
         Destroy(gameObject);
     }
 }
Esempio n. 2
0
 private void CheckBorders()
 {
     if (!GameAreaHelper.IsInGameplayArea(transform, _representation.bounds, Camera.main))
     {
         transform.position = startPoint.transform.position;
     }
 }
        private SpriteRenderer _representation; //reference to the moving object sprite

        protected override void Move(float amount, Vector3 axis)
        {
            // Only move if new position is in gemeply area (including bounds)
            var newPosition = transform.position + transform.TransformVector(amount * axis.normalized);

            if (!GameAreaHelper.IsInGameplayArea(newPosition, _representation.bounds, true))
            {
                return;
            }
            transform.position = newPosition;
        }