next tip   I wrote to : move player limit in view camera
code:












 //top-Right A
              Vector3 A= new Vector3(Camera.main.orthographicSize * Camera.main.aspect, Camera.main.orthographicSize, 0);
// down- Right B
                Vector3 B = new Vector3(Camera.main.orthographicSize * Camera.main.aspect, -Camera.main.orthographicSize, 0);
    //top -left C
                Vector3 C =new Vector3((-Camera.main.orthographicSize) * Camera.main.aspect, Camera.main.orthographicSize, 0);
    //down-left  D
                Vector3 D =new Vector3((-Camera.main.orthographicSize) * Camera.main.aspect, -Camera.main.orthographicSize,0);

                Vector3 Move = new Vector3(walkVec.x, walkVec.y, 0) * Time.deltaTime;
                Player.Translate(Move);
                if (Player.position.x > A.x)
                {
                    Player.position = new Vector3(A.x, Player.position.y, Player.position.z);
                }
                if (Player.position.x < D.x)
                {
                    Player.position = new Vector3(D.x, Player.position.y, Player.position.z);
                }
                if (Player.position.y > A.y)
                {
                    Player.position = new Vector3(Player.position.x, A.y, Player.position.z);
                }
                if (Player.position.y < B.y)
                {
                    Player.position = new Vector3(Player.position.x, B.y, Player.position.z);
                }

0 comments:

Post a Comment

Pin ThisShare on TumblrShare on Google PlusEmail This
 
Top