Created
May 30, 2019 17:50
-
-
Save gkagm2/b3649e30557ac7d5155d2fa340328937 to your computer and use it in GitHub Desktop.
2D 플레이어 x축 움직임 제한 함수
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 2D 플레이어 x축 움직임 제한 | |
private void ScreenCheck(){ | |
Vector3 worldPos = Camera.WorldToViewportPoint(this.transform.position); | |
if(worldPos.x < 0.05f) worldPos.x = 0.05f; | |
if(worldPos.x > 0.95f) worldPos.x = 0.95f; | |
this.transform.position = Camera.main.ViewportToWorldPoint(worldPos); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment