Newer
Older
CGTrack / Assets / Scripts / Bausatz / CartVR.cs
@Pascal Syma Pascal Syma on 25 Jul 2021 951 bytes Initial Commit
using System.Collections;
using System.Collections.Generic;
using DefaultNamespace;
using UnityEngine;
using UnityEngine.UI;

namespace Bausatz
{
    public class CartVR : MonoBehaviour
    {

        public Cart cart;
        public Text speedText;
        public Text accelText;
        
        // Update is called once per frame
        private void Update()
        {
            var stickR = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);

            cart.v += 0.1f * stickR.y;
            
            if (OVRInput.GetDown(OVRInput.Button.One))
            {
                cart.v = 0;
            }
            
            if (OVRInput.GetDown(OVRInput.Button.Two))
            {
                cart.u = 0;
                cart.v = 2.94f;
                cart.a = 0;
            }

            speedText.text = $"Speed: {Util.ms2kmh(cart.v):F1} km/h";
            accelText.text = $"Acceleration: {cart.a:F2} g";

        }
    }

}