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. Dismiss Notice

Question Camara Follows turn the screen in black

Discussion in '2D' started by benjaroman_84, Jun 14, 2021.

  1. benjaroman_84

    benjaroman_84

    Joined:
    Apr 26, 2021
    Posts:
    10
    Hey everybody, im working on a 2d platform game (still learning) and i made a script so the camara follows the main caracter, the only problem is once i run the game the camara takes the background color (black in this case) and it gives me a full screen of that

    upload_2021-6-14_0-38-53.png


    Here is the scrip im using

    public class CameraFollow : MonoBehaviour
    {
    public GameObject follow;
    public Vector2 minCamPos, maxCamPos;
    // Start is called before the first frame update
    void Start()
    {

    }
    // Update is called once per frame
    void FixedUpdate()
    {
    float posX = follow.transform.position.x;
    float posy = follow.transform.position.y;
    transform.position = new Vector3(
    Mathf.Clamp(posX, minCamPos.x, maxCamPos.x),
    Mathf.Clamp(posy, minCamPos.y, maxCamPos.y),
    transform.position.z);
    }
    }

    Can any1 give me a hand telling me what im doing wrong plz?

    Thank for your time ppl!
     

    Attached Files:

  2. benjaroman_84

    benjaroman_84

    Joined:
    Apr 26, 2021
    Posts:
    10
    Up just in case someone can give me a hand. Thanks!