LimitPosition
How do I use Limit Position
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
33 | LimitPosition (); | 1 |
77 | void LimitPosition(){ | 2 |
File name: PlayerController.cs
Copy
31 void Update () {
32 if (GameplayController.instance.gameInProgress) {
33 LimitPosition ();
34 if (Application.platform == RuntimePlatform.WindowsEditor) {
35 PlayerMovement ();
36 }else if(Application.platform == RuntimePlatform.Android){
37 TouchMovement ();
38 }
39
40 }
41 }
File name: PlayerController.cs
Copy
77 void LimitPosition(){
78 Vector3 leftBound = Camera.main.ViewportToWorldPoint (new Vector3 (0, 0, Camera.main.transform.position.z));
79 Vector3 rightBound = Camera.main.ViewportToWorldPoint (new Vector3 (1, 0, Camera.main.transform.position.z));
80
81 maxLeft = leftBound.x;
82 maxRight = rightBound.x;
83 }
LimitPosition 115 lượt xem
Gõ tìm kiếm nhanh...