동글 운항
This commit is contained in:
@@ -7,6 +7,8 @@ public class SteeringKeyXR : MonoBehaviour
|
||||
[Header("References")]
|
||||
[SerializeField] private XRGrabInteractable grabInteractable;
|
||||
[SerializeField] private Transform keyPivot;
|
||||
[SerializeField] private Transform handPoseRoot;
|
||||
[SerializeField] private bool keepHandPoseRootOnKeyPivot = true;
|
||||
|
||||
[Header("Steering")]
|
||||
[SerializeField] private float maxAngle = 45f;
|
||||
@@ -33,18 +35,24 @@ public float SteeringValue
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsGrabbed => isGrabbed;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (keyPivot == null)
|
||||
keyPivot = transform;
|
||||
|
||||
ResolveGrabInteractable();
|
||||
ResolveHandPoseRoot();
|
||||
ParentHandPoseRootToKeyPivot();
|
||||
initialPivotRotation = keyPivot.localRotation;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
ResolveGrabInteractable();
|
||||
ResolveHandPoseRoot();
|
||||
ParentHandPoseRootToKeyPivot();
|
||||
|
||||
if (grabInteractable != null)
|
||||
{
|
||||
@@ -114,6 +122,26 @@ private Vector3 GetInitialPivotSpaceDirection(Vector3 worldDirection)
|
||||
return Quaternion.Inverse(referenceRotation) * worldDirection;
|
||||
}
|
||||
|
||||
|
||||
private void ResolveHandPoseRoot()
|
||||
{
|
||||
if (handPoseRoot != null)
|
||||
return;
|
||||
|
||||
handPoseRoot = transform.Find("HandPoser");
|
||||
}
|
||||
|
||||
private void ParentHandPoseRootToKeyPivot()
|
||||
{
|
||||
if (!keepHandPoseRootOnKeyPivot || keyPivot == null || handPoseRoot == null)
|
||||
return;
|
||||
|
||||
if (handPoseRoot == keyPivot || handPoseRoot.parent == keyPivot)
|
||||
return;
|
||||
|
||||
handPoseRoot.SetParent(keyPivot, true);
|
||||
}
|
||||
|
||||
private void ResolveGrabInteractable()
|
||||
{
|
||||
if (grabInteractable != null)
|
||||
|
||||
Reference in New Issue
Block a user