Esempio n. 1
0
 //accessed by game controller when need to reset the player
 public void ResetAlto()
 {
     StopAlto();
     altoState = AltoBoardState.Static;
     HUDController.ActivateGameUI();
     //TODO: smooth teleportation of Alto player to start position
     transform.position = originPosition;
     AltoInput.ResetAlto();
 }
Esempio n. 2
0
        private void InitializeAltoController()
        {
            //was hoping to overwrite entire transform but read only have to set pos and rot separately
            SpeedUIPosition = new List <Vector3>();
            SpeedUIRotation = new List <Quaternion>();
            //Vive = 0, Oculus = 1, MR = 2, the same as the device enum values
            SpeedUIPosition.Add(new Vector3(0.0f, 0.01f, -0.052f));
            SpeedUIPosition.Add(new Vector3(0.018f, 0.007f, -0.05f));
            SpeedUIPosition.Add(new Vector3(0.0f, 0.009f, -0.051f));
            SpeedUIRotation.Add(Quaternion.Euler(270.0f, 0.0f, 0.0f));
            SpeedUIRotation.Add(Quaternion.Euler(305.0f, -1.0f, 13.5f));
            SpeedUIRotation.Add(Quaternion.Euler(285.0f, 0.0f, 0.0f));
            //TODO: add to this to cover all HMD's
            string device      = XRDevice.model;
            int    deviceIndex = -1;

            if (device.Contains("Oculus"))
            {
                currentDevice = HMDDevice.Oculus_Rift;
                //oculus buttons can only be accessed through SteamVR_Controller with openVR
                deviceIndex = (int)jetPackControl.controllerIndex; //if this controller device # is not set before play sometimes checks the class before it has started and returns 0
                if (deviceIndex == -1)
                {
                    deviceIndex = 1; Debug.Log("unable to find device index, please make sure controllers are on. Index set to 1");
                }
                oculusController = SteamVR_Controller.Input(deviceIndex);
            }
            else if (device.Contains("Vive"))
            {
                currentDevice = HMDDevice.HTC_Vive;
            }
            else
            {
                currentDevice = HMDDevice.MR_HMD;
            }
            //need the lists entries to match the device enum entries
            HUDController.ControllerSpeedUI.transform.localPosition = SpeedUIPosition[(int)currentDevice];
            HUDController.ControllerSpeedUI.transform.localRotation = SpeedUIRotation[(int)currentDevice];

            rigidBody      = GetComponent <Rigidbody>();
            originPosition = transform.position;
            altoHaptics    = gameObject.AddComponent <AltoHaptics>();
            //set variables from config
            rigidBody.mass        = AltoInput.GetConfigFloat("Player", "Mass");
            rigidBody.drag        = AltoInput.GetConfigFloat("Player", "Drag");
            rigidBody.angularDrag = AltoInput.GetConfigFloat("Player", "AngularDrag");
            step                   = AltoInput.GetConfigFloat("Player", "Step");
            userSpeed              = AltoInput.GetConfigFloat("Player", "UserStartingSpeed");
            AltoSpeed              = AltoInput.GetConfigFloat("Player", "AltoSpeed");
            UserSpeedIncremenet    = AltoInput.GetConfigFloat("Player", "UserSpeedIncrement");
            JetPackForce           = AltoInput.GetConfigFloat("Player", "JetPackForce");
            FallingForceAdjustment = AltoInput.GetConfigFloat("Player", "FallingForceAdjustment");
            calibDirection         = AltoInput.GetConfigFloat("Alto", "Offset");
            altoHoverAudio         = AltoPuck.GetComponent <AudioSource>();
            HUDController.SetSpeedRange(minSpeedMulitplier, maxSpeedMulitplier);
            setupComplete = true;
        }
Esempio n. 3
0
 void Update()
 {
     if (!isLocalPlayer)
     {
         return;
     }
     if (AltoInput.IsPresent())
     {
         ProcessAltoInput();
         if (!altoInactive)
         {
             ProcessAltoState();
         }
         altoHaptics.RunHapticFeedback(userVelocity, altoMagnitude);
     }
     else
     {
         //Debug.Log("Cannot detect Alto, check port and Alto.cfg");
     }
 }
Esempio n. 4
0
        ///Alto functions///
        private void ProcessAltoInput()
        {
            //get input values from Input class
            float altoInputDirection = AltoInput.GetDirection();

            Debug.Log("AltoInputDirection = " + AltoInput.GetDirection());
            float altoInputMagnitudeNorm = AltoInput.GetMagnitudeNormalised();

            Debug.Log("AltoInputMagnitudeNorm = " + AltoInput.GetMagnitudeNormalised());

            //apply to HUD GUI
            HUDController.UpdateMagnitude(altoInputMagnitudeNorm);
            altoDirection = (Quaternion.AngleAxis(altoInputDirection - calibDirection + 90, Vector3.up)) * calibVector;

            altoMagnitude = step * altoInputMagnitudeNorm;
            Vector3 PuckRot = Quaternion.AngleAxis(altoInputDirection + 90, Vector3.up) * Vector3.forward;

            AltoPuck.transform.eulerAngles = PuckRot * (altoInputMagnitudeNorm * 20);
            HUDController.SetAltoInput(altoDirection, altoMagnitude);
        }
Esempio n. 5
0
 private void HapticFeedback(string name, int intensity)
 {
     AltoInput.SendHapticCommand(name, intensity);
 }