Skip to content

Instantly share code, notes, and snippets.

@ohiofi
Created April 2, 2018 18:53
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 ohiofi/74b6cd9e59f44864a387ff2479e60196 to your computer and use it in GitHub Desktop.
Save ohiofi/74b6cd9e59f44864a387ff2479e60196 to your computer and use it in GitHub Desktop.
if (cameraTarget != null)
{
var newPos = Vector2.Lerp (transform.position, cameraTarget.position, Time.deltaTime * trackingSpeed);
var camPos = new Vector3 (newPos.x, newPos.y, -10f);
var v3 = camPos;
var clampX = Mathf.Clamp (v3.x, minX, maxX);
var clampY = Mathf.Clamp (v3.y, minY, maxY);
transform.position = new Vector3 (clampX, clampY, -10f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment