Created
April 2, 2018 18:53
-
-
Save ohiofi/74b6cd9e59f44864a387ff2479e60196 to your computer and use it in GitHub Desktop.
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
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