Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question something very simple about camera in 3D games

Discussion in 'Getting Started' started by roarcagra, Jun 21, 2023.

  1. roarcagra

    roarcagra

    Joined:
    Jun 21, 2023
    Posts:
    1
    i want that the camera change depends on the position of my "player", but im just started in this world and i dont know how this exactly works, i made this condicional that is called from update:
    void camSelector() {
    if (player.transform.position.x < 2.5)
    {
    cameras[0].gameObject.SetActive(true);
    cameras[1].gameObject.SetActive(false);
    camDirection(0);
    }
    else
    {

    cameras[1].gameObject.SetActive(true);
    cameras[0].gameObject.SetActive(false);
    camDirection(1);
    }
    }
    but it is too fast am the character get stuck when the camera change because the cameras are facing each other, and the forward direction in one is the back direction in the other, so it's like a loop
     
  2. RichAllen2023

    RichAllen2023

    Joined:
    Jul 19, 2016
    Posts:
    1,026
    2 things.

    CONDITIONAL, and use CODE tags.