Skip to content

Instantly share code, notes, and snippets.

@curious-username
Last active September 7, 2021 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curious-username/5a43ce4b994d13d2b9ea018eae815287 to your computer and use it in GitHub Desktop.
Save curious-username/5a43ce4b994d13d2b9ea018eae815287 to your computer and use it in GitHub Desktop.
Unity Example of border limits
if (transform.position.y > 5.7f)
{
transform.position = new Vector3(transform.position.x, 5.7f, 0);
}
else if (transform.position.y < -5.7f)
{
transform.position = new Vector3(transform.position.x, -5.7f, 0);
}
else if (transform.position.x > 11.35f)
{
transform.position = new Vector3(-11.35f, transform.position.y, 0);
}
else if (transform.position.x < -11.35f)
{
transform.position = new Vector3(11.35f, transform.position.y, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment