Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gkagm2/b3649e30557ac7d5155d2fa340328937 to your computer and use it in GitHub Desktop.
Save gkagm2/b3649e30557ac7d5155d2fa340328937 to your computer and use it in GitHub Desktop.
2D 플레이어 x축 움직임 제한 함수
// 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