Skip to content

Instantly share code, notes, and snippets.

@NickDiMucci
Created February 23, 2013 19:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save NickDiMucci/5020984 to your computer and use it in GitHub Desktop.
A poor way to keep a player within the screen bounds in a Unity script.
player.transform.position = new Vector3(
Mathf.Clamp(player.transform.position.x, -8.0f, 8.0f),
Mathf.Clamp(player.transform.position.y, -10.0f, 10.0f),
player.transform.position.z);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment