UniWii - WiiMote Values

Hello,

I’m working with a WiiMote, and I’m currently getting its values/data into Unity via the UniWii plugin.
It’s all working, but there seems to be one issue.

I have a cube in the scene thats shaped like the WiiMote, and I want to try and get the data from the actual WiiMote to change the rotation of the Scene WiiMote … eg: If I rotate (roll) my controller 20 degrees to the right, it will also rotate my game cube.

I’m currently resting my WiiMote on my desk and the roll values I’m getting is around -40 degrees, this cant be right can it? My cube has rolled -40 degrees on its Z rotation axis.

Am I doing this correctly?

wiiRoll = wiimote_getRoll(i);
wiiPitch = wiimote_getPitch(i);
wiiYaw = wiimote_getYaw(i);

var vec = new Vector3(0, 0, wiiRoll);
vec = Vector3.Lerp(oldVec, vec, Time.deltaTime * 10);
oldVec = vec;
	
cube.transform.eulerAngles = vec;

That sounds like a calibration issue. I think either you need to:

A. somehow recalibrate the WiiMote itself (maybe it got that roll offset when it was powered on / paired?)

or

B. add you own calibration with an offset. Basically you can just add wiiRollOffset, wiiPitchOffset and wiiYawOffset variables into the equation, eg:

wiiRoll = wiiRollOffset + wiimote_getRoll(i);

To calibrate / set the offset, just make a button or something which, when pressed, populates those offset variables with the inverse of the axis’ output (positive becomes negative and visa versa):

if (Input.GetButtonDown("Fire1"))
{
	wiiRollOffset = -1* wiimote_getRoll(i);
	wiiPitchOffset = -1* wiimote_getPitch(i);
	wiiYawOffset = -1* wiimote_getYaw(i);
}

Then place your WiiMote down flat and press said button. The cube in your scene should then be aligned with your WiiMote.

(Better late than never, right? Hopefully someone still finds this useful.)