using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.XR; using Valve.VR; public class AttachBikeToHead : MonoBehaviour { public Transform playerTransform; public Transform cameraTransform; public Transform bikeTransform; public float headHeihgt = 1.4f; public SteamVR_Action_Boolean resetAction; private SteamVR_Render render; private float initialBikeY; // Start is called before the first frame update void Start() { render = FindObjectOfType(); //initialBikeY = bikeTransform.position.y; ResetPositionAndRotation(); } private void ResetPositionAndRotation() { //bikeTransform.position = new Vector3(playerTransform.position.x, initialBikeY, playerTransform.position.z); //bikeTransform.rotation = playerTransform.rotation; //resetAction.AddOnStateUpListener(OnStateUp, SteamVR_Input_Sources.Any); //playerTransform.localPosition = new Vector3(0f, 1.32f, -0.8f); //playerTransform.localRotation = Quaternion.Euler(Vector3.zero); //cameraTransform.position = playerTransform.position; //cameraTransform.rotation = playerTransform.rotation; } private void OnStateUp(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { ResetPositionAndRotation(); } }