123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- 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 float initialBikeY;
- // Start is called before the first frame update
- void Start()
- {
- //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();
- }
- }
|