Como Convertir Un Videojuego Para Dodocase
by sabas1080 in Craft > Cardboard
1170 Views, 5 Favorites, 0 Comments
Como Convertir Un Videojuego Para Dodocase



En esta ocasión vamos a mostrar como convertir un videojuego normal en uno para los Dodocase o CardBoard, una actividad que realizamos durante la BuildNight de Octubre en el hackerspace The Inventor's House
En esta ocasión usaremos el juego creado por Khevna
Requerimientos:
- Unity 4
- Plugin Dive https://www.durovis.com/index.html
- Android 4.0
Queremos aclarar que este instructable esta basado en el de Khevna
Añadir Plugin


Descargamos de la pagina oficial el plugin y damos doble clic en el archivo, se abrirá una ventana como la que aparece en las imágenes y presionamos el botón importar para tenerlo en nuestro IDE
Añadir Las Dos Camaras

Ahora en la sección de Assets aparece una carpeta llamada Dive lo seleccionamos y arrastramos al personaje
Código Para Detección Del Iman

En esta ocasión el imán de nuestros dodocase nos servirá como botón de acción para que nuestro personaje pueda disparar, les dejamos el código usado
* “Globals” script *
static var initialrv : int = 0; // Raw compass vector to test the magnet against static var prevrv : int = 0; // Raw compass vector to verify that initialrv is valid static var initialrot : ScreenOrientation;
function Start ()
{ initialrot = Screen.orientation; Input.compass.enabled = true; }
function Update () {
// Catch if the initialrv is completely wrong
// (sometimes the magnitude can jump from // 15 to 400, depending on how the player // rotates the device). // if (prevrv > initialrv * 23) { initialrv = Mathf.RoundToInt(Input.compass.rawVector.magnitude); }
// Catch if the user flips the screen to change the orientation
// if (initialrot != Screen.orientation || initialrv == 0) { initialrot = Screen.orientation; initialrv = Mathf.RoundToInt(Input.compass.rawVector.magnitude); }
// Catch if the magnitude has fallen by a
// huge amount since the last update // var vectest = Mathf.RoundToInt(Input.compass.rawVector.magnitude); if (initialrv > vectest * 23) { initialrv = Mathf.RoundToInt(Input.compass.rawVector.magnitude); }
// Refresh prevrv to test against at the start of the next update
// prevrv = Mathf.RoundToInt(Input.compass.rawVector.magnitude); }
* “GameLogic” script *
// assuming the initialrv from the global script is roughly
// consistent with the current magnitude before a button // is pressed, we can test against it. If the magnitude raises // two-fold, it indicates that the magnetic button has been // pressed. If the magnitude raises by 23 times or more, it // indicates a false-positive, at which point the initialrv is reset. // var vectest = Mathf.RoundToInt(Input.compass.rawVector.magnitude); if (vectest > Globals.initialrv * 2)
{ // Magnet button down
fire();
}
Este código esta tomado de http://www.sc0ttgames.com/?p=293
Hora De Probar

Ahora solo es generar el APK y probar en nuestro smartphone con nuestros Dodocase
Les dejo el repositorio de proyecto para que lo puedan descargar y hacer la modificaciones necesarias
GitHub: https://github.com/sabas1080/DodocaseGame
Gracias a Jesús Ignacio por compartir este proyecto en la BuildNight
Saludos