Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (player != null)
     {
         if (isRight)
         {
             if (!active && player.transform.position.x >= this.transform.position.x)
             {
                 active = true;
                 smoothFollowScript.SetFollow(false);
                 boundary.transform.position = camera.ViewportToWorldPoint(Vector3(1, 1, camera.nearClipPlane));
             }
             else if (active && player.transform.position.x <= this.transform.position.x)
             {
                 active = false;
                 smoothFollowScript.SetFollow(true);
             }
         }
         else
         {
             if (!active && player.transform.position.x < this.transform.position.x)
             {
                 active = true;
                 smoothFollowScript.SetFollow(false);
             }
             else if (active && player.transform.position.x > this.transform.position.x)
             {
                 active = false;
                 smoothFollowScript.SetFollow(true);
             }
         }
     }
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (player != null)
        {
            if (isRight)
            {
                if (!active && player.transform.position.x >= this.transform.position.x)
                {
                    active = true;
                    smoothFollowScript.SetFollow(false);

                    Vector3 pos = new Vector3(1, 0.5f, camera.nearClipPlane);
                    boundary.transform.position = camera.ViewportToWorldPoint(pos);

                    if (!boundary.activeSelf)
                    {
                        boundary.SetActive(true);
                    }
                }
                else if (active && player.transform.position.x <= this.transform.position.x)
                {
                    active = false;
                    smoothFollowScript.SetFollow(true);
                }
            }
            else
            {
                if (!active && player.transform.position.x < this.transform.position.x)
                {
                    active = true;
                    smoothFollowScript.SetFollow(false);

                    Vector3 pos = new Vector3(0, 0.5f, -camera.nearClipPlane);
                    boundary.transform.position = camera.ViewportToWorldPoint(pos);

                    if (!boundary.activeSelf)
                    {
                        boundary.SetActive(true);
                    }
                }
                else if (active && player.transform.position.x > this.transform.position.x)
                {
                    active = false;
                    smoothFollowScript.SetFollow(true);
                }
            }
        }
    }