mirror of
https://github.com/ganeshsar/UnityPythonMediaPipeBodyPose.git
synced 2025-07-07 03:07:36 +08:00

Major Release: - made the correct flip options the default (to revert: uncomment in Landmark.cs, and uncomment cv2.flip) - switch between the traditional anchored landmarks versus the full 3D movement using the appropriate Boolean in the unity inspector
32 lines
903 B
C#
32 lines
903 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CameraController : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private float distance = 10f;
|
|
public Vector3 offset;
|
|
|
|
Transform focus;
|
|
Vector3 originalDelta;
|
|
|
|
public void Calibrate(Transform focus)
|
|
{
|
|
this.focus = focus;
|
|
originalDelta = transform.position - focus.position;
|
|
originalDelta.x *= .01f;
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (focus == null) return;
|
|
|
|
Vector3 t = focus.position+offset*.5f + (originalDelta.normalized * (distance));
|
|
transform.position = Vector3.Lerp(transform.position, t, Time.deltaTime*2.5f);
|
|
|
|
Quaternion r = Quaternion.LookRotation((focus.position+offset - transform.position).normalized, Vector3.up);
|
|
transform.rotation = Quaternion.Lerp(transform.rotation, r, Time.deltaTime * 1f);
|
|
}
|
|
}
|