Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Camera problem

Discussion in 'Editor & General Support' started by Roirtur, Jun 22, 2019.

  1. Roirtur

    Roirtur

    Joined:
    Jun 18, 2019
    Posts:
    4
    Hello ! I'm trying to set a camera on my game but I have a problem, how can I get player position from a script attached to the camera ? or how can I moove the camera from a script attached to the player ?
    Please help me....
    Thank u :)
     
  2. ManuelSegura

    ManuelSegura

    Joined:
    Dec 12, 2015
    Posts:
    19
    References!

    In the player script write: public CameraScript camera;
    In the camera script write: public PlayerScript player;

    If you only want the position you can reference they transforms:

    In the player script write: public Transform cameraT;
    In the camera script write: public Transform playerT;

    Also, watch some Youtube tutorials before posting more questions, they are waaaay better general teachers than random forum posts, specially for beginners.