private void UpdateCameraFollowing() { for (int i = 0; i < following_items.Count; ++i) { CameraFollowItem curr_item = following_items[i]; float movement_time = curr_item.GetMovementTime(); Vector3 offset = curr_item.GetOffset(); Camera camera = curr_item.GetCamera(); Transform following_trans = curr_item.GetFollowingGameObject().transform; Vector3 desired_pos = following_trans.position + offset; Vector3 smoothed_position = Vector3.SmoothDamp(camera.transform.position, desired_pos, ref curr_item.velocity, movement_time); if (!camera.orthographic) { camera.transform.position = smoothed_position; } else { camera.transform.position = new Vector3(smoothed_position.x, smoothed_position.y, camera.transform.position.z); } } }
public void CamerasStopFollow(GameObject go) { for (int i = 0; i < following_items.Count;) { CameraFollowItem curr_item = following_items[i]; if (curr_item.GetFollowingGameObject() == go) { following_items.RemoveAt(i); } else { ++i; } } }