android - How to handle input via Bluetooth in Google Cardboard? -


i using google cardboard sdk along unity 3d build first unity tutorial (roll ball) google cardboard. need move main player ball (the white 1 in tutorial) collect small yellow cubes.now,google cardboard allows head tracking along single switch (magnetic/conductive foam) out of box.in order move ball,i need attach controller.

this plan -> buy joystick. connect arduino. attach bluetooth module arduino.

i need know how receive bluetooth data in game. should code inside main player script's void update() method?

any appreciated. thank :)

don't why need arduino.

i made cardboard game (flight simulator type). bought ipega 9028 gamepad aliexpress. binded android / iphone , thats it. (unless phone doesnt have bluetooth... in case should invest in new phone not in new arduino :) )

in unity app, first need bind keys , save them in playerprefs, because have no way of knowing button / axis translates unity button number / axis number.

so in input manager in unity need define possible buttons , axis joystick number 1. , unity, create key binding menu. there should have user click bind button each option (like move, shoot, go up, go down etc..) , once clicks need have 2 "for loops". 1 looks input on button numbers (input.getbutton), , 1 looks input on joystick axis (input.getaxis). according names you've created them in input manager.

once detect input, should store it's name in playerprefs along action it's suppose bind to.

you should make users once after install game. because each gamepad transmits different codes unity. example left analog stick, can't know in advance axis correspond in unity.

then in game read these values playerprefs on start() , know input listen each action.

i hope clear.

p.s. usb joystick have easy time testing on development machine.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -