Beispiel #1
0
        // Update is called once per frame
        void Update()
        {
            if (hero == null)
            {
                return;              //Why?
            }
            for (int i = 0; i < bgs.data.Length; i++)
            {
                bgscrolldata current = bgs.data[i];
                Vector3      offset  = current.endHeight - current.beginHeight;

                if (MainHelper.Instance.CurrentCamera.transform.position.y < current.endHeight.y)
                {
                    offset = Vector3.Scale(MainHelper.Instance.CurrentCamera.transform.position - current.beginHeight, Vector2.one);
                }

                offset.Scale(current.multiplyer);
                //Vector2.Scale(speed,direction) * Time.deltaTime;

                //Temporarily deal with beginheight
                if (MainHelper.Instance.CurrentCamera.transform.position.y < current.beginHeight.y)
                {
                    offset += new Vector3(450, 0, 0);
                }

                current.gameObject.transform.position = current.beginPosition + offset + current.beginHeight;
            }
        }
        // Update is called once per frame
        void Update()
        {
            if (hero == null)
            {
                return;              //Why?
            }
            for (int i = 0; i < bgs.data.Length; i++)
            {
                bgscrolldata current = bgs.data[i];
                Vector3      offset  = current.endHeight - current.beginHeight;

                if (hero.transform.position.y < current.endHeight.y)
                {
                    offset = Vector3.Scale(hero.transform.position - current.beginHeight, Vector2.one);
                }

                offset.Scale(current.multiplyer);
                //Vector2.Scale(speed,direction) * Time.deltaTime;
                current.gameObject.transform.position = current.beginPosition + offset;
            }
        }