Flafla2 / Unity-Wiimote

An easy to use interface between Unity3D / C# and a Wii Remote controller.
MIT License
329 stars 73 forks source link

BB not set to an instance of an object #28

Open FlameInABox opened 8 years ago

FlameInABox commented 8 years ago

Hey, Thanks for the great work on the wii plug in.

I'm currently going through the demo scene to test if my controller works fine. At the moment the button input is working fine and it registers if I'm pressing them. One thing I can't seem to get working is the motion of moving the wii remote around to point at a position on the screen. Also I'm getting errors related to the BB game objects, not sure what they are, I've included an image to show things a little better.

wiibbnotset

Flafla2 commented 8 years ago

I believe this bug was fixed in the source repository, but not in the current release. Could you please try that? You can download the latest source by clicking "Download ZIP" on the main repo page.

FlameInABox commented 8 years ago

Hey, I've downloaded the version you suggested from the main repo page and tried it again, still no success and I'm having the same issue. I want to experiment further and see if I was going wrong anywhere with my set up but my wii mote just died so I will have to wait until the morning for now.

https://www.youtube.com/watch?v=co7xggFfE94

Going from your video I want to try and implement 4. IR camera support.

My game I'm currently working on is finished and works at the moment using mouse and keyboard as input devices. I was hoping to implement the wii mote as the input instead using the A and B button, and also using the wii mote point location instead of the mouse cursor location for aiming.

From earlier it seemed it detected the button presses perfectly fine, I just couldn't get it to look around like you did in your video. Is there something I'm missing?

Also what exactly is the BB game object, what does it stand for and what is the purpose of the 4 children?

I'd imagine to get my wii mote point on screen to work I will have to run the IR Setup Sequence. With there being 3 options though being basic, extended and full, what are the differences between them.

Sorry if I seem to be clueless but I was hoping to implement this in to my game and this looks like the best solution.

Is there something I've missed or some form of instructions I could go through to setting up the demo?

Thanks.

Flafla2 commented 8 years ago

The differences between Basic, Extended, and Full are listed in the API documentation (see docs/index.html in the release ZIP). The following table is taken from the enum IRDataType Documentation:

Type Description
BASIC 10 bytes of data. Contains position data for each dot only.
EXTENDED 12 bytes of data. Contains position and size data for each dot.
FULL 36 bytes of data. Contains position, size, bounding box, and intensity data for each dot.

There is more information in the full docs (such as what data report types can be used with each IR mode, etc). The "BB" gameobject is used to visualize the FULL data type bounding boxes - these aren't necessary if you just want the pointing position. I have run into problems with these masks before, but only in earlier unity versions. What Unity version are you currently running? I am using the latest version (5.3.4). In any case the errors are a Unity bug only related to the demo scene, not to the API itself, so they shouldn't stop you from implementing the API on your own.

I highly recommend reading through the documentation (there is a really nice overview of the API included there as well, I put a lot of time into it :smile:).

FlameInABox commented 8 years ago

Thanks, I've been meaning to go through the documentation. Also I don't know if this is a cause for potential errors but haven done a bit of research I've discovered my remote ID when connected via bluetooth is Nintendo-RVL-CNT-01-TR. I've seen a lot of people complaining about this type of remote, not particularly with this package but with other ones as well.

Flafla2 commented 8 years ago

Most of the problems with TR remotes have to do with connecting them to Windows 10... it appears you have already done that though so you shouldn't have issues with that remote specifically.

maxosprojects commented 8 years ago

Having the same issue with the same controller. Neither accelerometer data, nor IR data is ever reported. The only place that is ever hit is

case InputDataType.REPORT_BUTTONS:

in Wiimote.cs

I have made sure the reporting mode is set and the return from the call is 0. I even enabled RumbleOn to confirm that the reporting mode change command is received by the controller.

Unity 5.4.0.f3 Windows 10 Latest Unity-Wiimote (master)

http://wiibrew.org/wiki/Wiimote has not changed since 15 December 2014, so I doubt I'd find anything new there that you have not implemented.

Any hints would be much appreciated. I'm also willing to dig deeper to provide more info/test stuff.

Thanks.

Flafla2 commented 8 years ago

@maxosprojects It appears your issue is unreleated to this thread. Also, it appears that REPORT_BUTTONS is the current reporting mode, and you haven't actually changed it successfully. Have you read through the documentation? See the docs folder included in the latest release

maxosprojects commented 8 years ago

It is related. Regardless of which mode I set it still reports only button events. I use the demo project and tried all the reporting modes there are. I have not only read the docs, but looked through the code too.

Perhaps you missed the following in my post:

I have made sure the reporting mode is set and the return from the call is 0. I even enabled RumbleOn to confirm that the reporting mode change command is received by the controller.

LED do not react either. However, dolphin-emu manages to set one of the LEDs on as part of initialization sequence.

Flafla2 commented 8 years ago

@maxosprojects This thread is about the "BB not set to an instance of an object" error, which was affecting users of Unity 5.3.x prior to 5.3.4. This is a UI bug in the demo scene and has nothing to do with any bugs in the API itself. This is what I was referring to by the "unrelated" comment.

In any case, can you elaborate specifically as to what you are trying to do? Are you using the demo scene or your own code? From how I read what you wrote you found a bug using your own code and confirmed it with the demo scene? If you are using the demo scene, make sure you run the IR setup sequence first (and in your own code too, for that matter).

maxosprojects commented 8 years ago

Apologies for not getting your point.

Hmm, perhaps the title is not stating the main issue. FlameInABox described comms problem first and then added:

Also I'm getting errors related to the BB game objects

Since you're fine with continuing comms discussion in this thread... Yes, I'm using the demo scene, originally there was no code other than from the repo (current master). I thought the Basic button runs the IR sequence. But just to be safe I changed one of the buttons to do:

if (GUILayout.Button("But/Acc/IR12", GUILayout.Width(300 / 4)))
{
    wiimote.SetupIRCamera();
    wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_IR12);
}

Nothing helps. Why would LEDs not get set? That is the simplest thing. Rumble works, though.