- Home /
Question by
Horsepower · Mar 26, 2012 at 08:59 AM ·
inputgyrowiimote
Why Wiimote (or Glovepie, or Unity3D...) pull in the above-left corner ?
I made this simple script for “Glovepie” :
**************************Joystick Virtuale - Modificato da Dario Cavallo.
wiimote1.Led1 = true
// Variabili (wiimote.gy non è utilizzato)
var.xRot = Wiimote.gx
var.yRot = Wiimote.gy
var.zRot = Wiimote.gz
debug = 'X:' + var.xRot + ', ' + 'Y:' + var.yRot + ', ' + 'Z:' + var.zRot
**************************Assi Analogici Wiimote
// Destra / Sinistra
ppjoy.Analog0 = -maprange (smooth(Wiimote.gx, 5) , -1 degrees, 1 degrees, -1 , 1)
// Su / Giù
ppjoy.Analog1 = -maprange (smooth(Wiimote.gy, 5) , -1 degrees, 1 degrees, -1 , 1)
// Asse-gY (Da Non utilizzare:
// ppjoy.Analog XX = -maprange (Wiimote.gy, -90 degrees, 90 degrees, -25 , 25)
**************************Assi Analogici Nunchuk
// Su / Giù
//ppjoy.Analog2 = -wiimote.Nunchuk.gz
// Sinistra / Destra
//ppjoy.Analog3 = -wiimote.Nunchuk.gx
// POV
//ppjoy.Analog8 = -maprange (wiimote.Nunchuk.JoyX, -90 degrees, 90 degrees, -180 , 180)
**************************Assegnazione Tasti
ppjoy1.Digital0 = wiimote1.A
ppjoy1.Digital1 = wiimote1.B
ppjoy1.Digital2 = wiimote1.Minus
ppjoy1.Digital3 = wiimote1.Home
ppjoy1.Digital4 = wiimote1.Plus
ppjoy1.Digital5 = wiimote1.One
ppjoy1.Digital6 = wiimote1.Two
// Tasti Direzionali
ppjoy1.Digital7 = wiimote1.Up
ppjoy1.Digital8 = wiimote1.Down
ppjoy1.Digital9 = wiimote1.Left
ppjoy1.Digital10 = wiimote1.Right
// Tasti Nunchuk
//ppjoy1.Digital10 = wiimote.Nunchuk.Zbutton
//ppjoy1.Digital11 = wiimote.Nunchuk.Cbutton
// Wiimote speaker
// wiimote1.Frequency = 1500
// wiimote.volume = 5%
This works very well, with little rotational movement og Wiimote gyro, it is possible to achieve a good sensivity!
But the problem is:
1) Why Wiimote (or Glovepie, or Unity3D, I am not sure…) pull in the above-left corner of the screen?
2) In Unity3D the 3D object slide over a table fortunately, and all works correctly…
3) But why happens, this behaviour?
(...In Unity3D I added the "Slerp" function, to remove the Wiimote gyro flickering, and made some correction to the "Rotate Behaviour Script"...):
var maxVert: float = 90; // define the max vertical angle (to each side)
var maxHor: float = 90; // define the max horizontal angle (to each side)
private var initRot: Quaternion;
function Start(){
initRot = transform.rotation;
}
function Update(){
var angV = Input.GetAxis("Vertical") * maxVert;
var angH = Input.GetAxis("Horizontal") * maxHor;
var target = initRot * Quaternion.Euler(-angV, 0, angH);
// Dampen towards the target rotation
transform.rotation = Quaternion.Slerp(transform.rotation, target,
Time.deltaTime * 1);;
}
Please, hurry, response me!
It’s urgent!
Thanks you!
Horsepower.
Comment