// Start is called before the first frame update
 void Start()
 {
     levelGeneratorObj               = GameObject.FindObjectOfType <LevelGenScript>();
     BgLength                        = (float)levelGeneratorObj.levelLength;
     gameObject.transform.position   = new Vector3(0, 0, 0);
     gameObject.transform.localScale = new Vector3(BgLength * 3.5f, BgLength * 3.5f, 0);
 }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        levelGeneratorObj = GameObject.FindObjectOfType <LevelGenScript>();
        float camHorizontalExtend = cam.orthographicSize * Screen.width / Screen.height;
        float halfHeight          = cam.orthographicSize;
        float halfWidth           = cam.aspect * halfHeight;

        maxPosition = new Vector2(levelGeneratorObj.levelLength - offset1, levelGeneratorObj.levelLength - offset1);
        minPosition = new Vector2(-levelGeneratorObj.levelLength + offset1, -levelGeneratorObj.levelLength + offset1);

        //Calculate and store the offset value by getting the distance between the player's position and camera's position.
        offset = transform.position - player.transform.position;
    }