Created
January 24, 2016 04:34
-
-
Save moon-goon/41a345b05f6fc34ef704 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public GameObject targetObj; | |
public float smooth = 1; | |
Vector3 offsetValue; | |
void Start() { | |
offsetValue = transform.position - targetObj.transform.position; | |
} | |
void LateUpdate() { | |
Vector3 initPosition = targetObj.transform.position + offsetValue; | |
Vector3 position = Vector3.Lerp(transform.position, initPosition, Time.deltaTime * smooth); | |
transform.position = position; | |
transform.LookAt(targetObj.transform.position); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment