Fixed player location calculation via camera trigger collider

This commit is contained in:
2025-10-17 17:17:41 +03:00
parent 013ed4944c
commit 2e61259ebe
40 changed files with 7649 additions and 1707 deletions

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HandPresencePhysics : MonoBehaviour
{
public Transform target;
private Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate()
{
//position
rb.velocity = (target.position - transform.position) / Time.fixedDeltaTime;
//rotation
Quaternion rotationDifference = target.rotation * Quaternion.Inverse(transform.rotation);
rotationDifference.ToAngleAxis(out float angleInDegree, out Vector3 rotationAxis);
Vector3 rotationDifferenceInDegree = angleInDegree * rotationAxis;
rb.angularVelocity = (rotationDifferenceInDegree * Mathf.Deg2Rad / Time.fixedDeltaTime);
}
}