private void Update()
{
speed = sliderSpeed.value;
follower.transform.position = Vector3.Lerp(follower.transform.position, transform.position + followerOffset, speed);
if (lookAt.isOn) follower.transform.LookAt(transform.position);
}
private void OnMouseDown()
{
screenPoint = Camera.main.WorldToScreenPoint(transform.position);
offset = transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
}
private void OnMouseDrag()
{
Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
transform.position = curPosition;
}
-
Notifications
You must be signed in to change notification settings - Fork 7
markulie/unity-smooth-follow
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Unity Smooth Follow with Lerp