Exemple #1
0
        private void HandleOutOfBounds()
        {
            if (!TeleportIfOutOfBounds)
            {
                return;
            }

            var sceneController = SharedUtils.TryGetSceneController() as WorldSceneController;

            if (sceneController != null)
            {
                if (!sceneController.WorldBounds.Contains(transform.position))
                {
                    Debug.LogWarning("Player out of bounds, teleporting!");

                    Vector3    teleportPoint = sceneController.WorldBounds.center + new Vector3(0, 2f, 0);
                    GameObject spawnPoint    = WorldUtils.FindPlayerSpawn();
                    if (spawnPoint != null)
                    {
                        teleportPoint = spawnPoint.transform.position;
                    }
                    transform.position = teleportPoint;
                    Velocity           = Vector3.zero;
                }
            }
        }