Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

Exagerar movimiento HTC

Iniciado por SaraW, Junio 19, 2017, 10:58:04 AM

Tema anterior - Siguiente tema
Junio 19, 2017, 10:58:04 AM Ultima modificación: Junio 19, 2017, 11:04:00 AM por SaraW
¡Buenos días  foreros! Espero que muchos de vosotros también estéis trabajando con las HTC...
 
Mi duda es: ¿La Script "SteamVR_TrackedObject" (la adjunto) controla el movimiento/posicionamiento del casco?. Mi idea es "exagerar" ese movimiento para que cuando el jugador en la vida real haga un paso, en Unity haga como 5 (para entendernos). El problema es que voy cortita de conocimiento de Scripts. ¿Alguien ya ha hecho esto?
 
Saludos
 
 
 



   
       
   
   
      //======= Copyright (c) Valve Corporation, All rights reserved. ===============

      //

      // Purpose: For controlling in-game objects with tracked devices.

      //

      //=============================================================================
   
   
      using UnityEngine;

      using Valve.VR;
   
   
      public class SteamVR_TrackedObject : MonoBehaviour

      {

          public enum EIndex

          {

              None = -1,

              Hmd = (int)OpenVR.k_unTrackedDeviceIndex_Hmd,

              Device1,

              Device2,

              Device3,

              Device4,

              Device5,

              Device6,

              Device7,

              Device8,

              Device9,

              Device10,

              Device11,

              Device12,

              Device13,

              Device14,

              Device15

          }
   
   
          public EIndex index;

          public Transform origin; // if not set, relative to parent

          public bool isValid = false;
   
   
          private void OnNewPoses(TrackedDevicePose_t[] poses)

          {

              if (index == EIndex.None)

                  return;
   
   
              var i = (int)index;
   
   
              isValid = false;

              if (poses.Length <= i)

                  return;
   
   
              if (!poses.bDeviceIsConnected)

                  return;
   


   

              if (!poses
.bPoseIsValid)

                  return;
   


   

              isValid = true;
   


   

              var pose = new SteamVR_Utils.RigidTransform(poses
.mDeviceToAbsoluteTracking);
   


   

              if (origin != null)


              {


                  transform.position = origin.transform.TransformPoint(pose.pos);


                  transform.rotation = origin.rotation * pose.rot;


              }


              else


              {


                  transform.localPosition = pose.pos;


                  transform.localRotation = pose.rot;


              }


          }
   


   

          SteamVR_Events.Action newPosesAction;
   


   

          void Awake()


          {


              newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses);


          }
   


   

          void OnEnable()


          {


              var render = SteamVR_Render.instance;


              if (render == null)


              {


                  enabled = false;


                  return;


              }
   


   

              newPosesAction.enabled = true;


          }
   


   

          void OnDisable()


          {


              newPosesAction.enabled = false;


              isValid = false;


          }
   


   

          public void SetDeviceIndex(int index)


          {


              if (System.Enum.IsDefined(typeof(EIndex), index))


                  this.index = (EIndex)index;


          }


      }
   


   

   


   


       
   





[/quote]


 

Etiquetas: