Ejemplo n.º 1
0
    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);
            }
        }
    }
Ejemplo n.º 2
0
    public void CameraUpdateFollow(Camera camera, float movement_time, Vector3 offset)
    {
        for (int i = 0; i < following_items.Count; ++i)
        {
            CameraFollowItem curr_item = following_items[i];

            if (curr_item.GetCamera() == camera)
            {
                curr_item.SetMovementTime(movement_time);
                curr_item.SetOffset(offset);
            }
        }
    }
Ejemplo n.º 3
0
    public void CameraStopFollow(Camera camera)
    {
        for (int i = 0; i < following_items.Count; ++i)
        {
            CameraFollowItem curr_item = following_items[i];

            if (curr_item.GetCamera() == camera)
            {
                following_items.RemoveAt(i);

                break;
            }
        }
    }