Ejemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            CharacterController2D controller = collision.gameObject.GetComponent <CharacterController2D>();
            CharacterInteractions ch         = collision.gameObject.GetComponent <CharacterInteractions>();

            ch.InteractionsEnabled        = true;
            controller.MovementEnabled    = true;
            controller.WalkRightEndlessly = false;
        }
    }
Ejemplo n.º 2
0
    private void DisplaceObjects(int sceneIndex)
    {
        Scene     scene               = SceneManager.GetSceneByBuildIndex(sceneIndex);
        Camera    mainCamera          = Camera.main;
        Transform mainCameraTransform = mainCamera.transform;

        float screenAspect  = (float)Screen.width / (float)Screen.height;
        float camHalfHeight = mainCamera.orthographicSize;
        float camHalfWidth  = screenAspect * camHalfHeight;
        float camWidth      = 2.0f * camHalfWidth;

        for (int i = 0; i < scene.GetRootGameObjects().Length; i++)
        {
            Transform t = scene.GetRootGameObjects()[i].transform;

            if (t.gameObject.CompareTag("Player"))
            {
                t.position = t.position + new Vector3(
                    camWidth,
                    0.0f,
                    0.0f);

                CharacterController2D cc = t.gameObject.GetComponent <CharacterController2D>();
                cc.MovementEnabled = false;
                CharacterInteractions ch = t.gameObject.GetComponent <CharacterInteractions>();
                ch.InteractionsEnabled = false;

                cc.WalkRightEndlessly = true;
            }
            else
            {
                t.position = t.position + new Vector3(
                    camWidth,
                    0.0f,
                    0.0f);
            }
        }
    }
Ejemplo n.º 3
0
 private void OnEnable()
 {
     characterController   = FindObjectOfType <CharacterController2D>();
     characterInteractions = characterController.GetComponent <CharacterInteractions>();
 }