This repository has been archived on 2026-01-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Frontec/Assets/Scripts/VR/AvatarInputConverter.cs
jmaniuvc 2936c48466 Frontec
2025-02-24 12:12:52 +09:00

43 lines
1.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AvatarInputConverter : MonoBehaviour
{
//Avatar Transforms
public Transform MainAvatarTransform;
public Transform AvatarHead;
public Transform AvatarBody;
public Transform AvatarHand_Left;
public Transform AvatarHand_Right;
//XRRig Transforms
public Transform XRHead;
// public Transform XRHand_Left;
// public Transform XRHand_Right;
public Vector3 headPositionOffset;
public Vector3 handRotationOffset;
// Update is called once per frame
void Update()
{
//Head and Body synch
MainAvatarTransform.position = Vector3.Lerp(MainAvatarTransform.position, XRHead.position + headPositionOffset, 0.5f);
AvatarHead.rotation = Quaternion.Lerp(AvatarHead.rotation, Quaternion.Euler(new Vector3(XRHead.rotation.x - 90 , XRHead.rotation.y, XRHead.rotation.z)) , 0.5f);
AvatarBody.rotation = Quaternion.Lerp(AvatarBody.rotation, Quaternion.Euler(new Vector3(-90, AvatarHead.rotation.eulerAngles.y, 0)), 0.05f);
//Hands synch
// AvatarHand_Right.position = Vector3.Lerp(AvatarHand_Right.position,XRHand_Right.position,0.5f);
// AvatarHand_Right.rotation = Quaternion.Lerp(AvatarHand_Right.rotation,XRHand_Right.rotation,0.5f)*Quaternion.Euler(-handRotationOffset);
// AvatarHand_Left.position = Vector3.Lerp(AvatarHand_Left.position,XRHand_Left.position,0.5f);
// AvatarHand_Left.rotation = Quaternion.Lerp(AvatarHand_Left.rotation,XRHand_Left.rotation,0.5f)*Quaternion.Euler(handRotationOffset);
}
}