Need some help with C# bools and Javascript booleans please

I’m working out the final few issues with my game using Wii Remotes and I’ve hit a stumbling block.

I’m trying to get the “A” button on my remote to work.

I have it being accessed by my C# script, and Im trying to pass it to my Javascript so I can use it in an if statement (if A is pressed, boolean = true, so shoot).

My javascript looks like:

import System; 

var target : Transform; 
var projectile : Rigidbody;
static var screenheight: int = Screen.height;
//var screenwidth: int = 1900;
var myX: int=6; 
var myY: int=6; 
var p = Vector3(0,0,0);
var AbButton : boolean = true;

function Update() 
{ 
var wm = target.gameObject.GetComponent(WiiMote); 

  if (AbButton==true)
		{		
		var instantiatedProjectile : Rigidbody = Instantiate(
				projectile,p, transform.rotation);
				

		Physics.IgnoreCollision( instantiatedProjectile. collider,
			transform.root.collider );
				
				}



Debug.Log("Cursor x = "+wm.cursorX+" Cursor y = "+wm.cursorY); 
myX = wm.cursorX; 
myY = wm.cursorY;  
AButton = wm.getA;
Debug.Log("myX = "+myX+" myY = "+myY); 
wm.CommsTest(); 
}

And the relevant c# looks like:

using UnityEngine; 
using System; 
using System.Collections; 
using System.Runtime.InteropServices; 

public class WiiMote : MonoBehaviour { 

[DllImport ("UniWii")]
	private static extern bool wiimote_getButtonA(int which);


	public bool getA = true;


 void FixedUpdate () { 
	getA = wiimote_getButtonA();

.....

This is kicking up an error CS15015: No overload for method ‘wiimote_getButtonA’ takes ‘0’ arguments.

I’ve searched through Microsofts site, and the unity scripting manual, but I’ve run out of ideas.

Any help would once again be greatly appreciated, this forum has been invaluable to this project so far!

private static extern bool wiimote_getButtonA(int which);

So you define the function as taking an integer parameter.

getA = wiimote_getButtonA();

Then you try to call it without passing an integer parameter.

And the compiler says

The compiler seems to be right. You can’t define a method with one signature and call it with another. You can have multiple methods of the same name with different signatures, but I don’t think that’s what you wanted here.

Ok thanks, I think I’m following, I have no c# experience, which is why I’m just trying to get the reading from private static extern bool wiimote_getButtonA(int which); in the Javascript via a public variable so I can “fire” when A is pressed, and leave the C# alone as much as possible.

The

private static extern bool wiimote_getButtonA(int which);

should return either “true” or “false”, I am assuming? Depending on whether “A” is being pressed or not.

I’m not quite sure what I should be putting in the parenthesis of;

getA = wiimote_getButtonA();

thought it might be after a default value (of false, as “A” is not being pressed). But I think I’m thoroughly confusing myself now.

I believe what you want to do is something like this:

getA = wiimote_getButtonA(0);

Where the integer in the wiimote_getButtonA parameter is the ID of what wiimote is connected.

0 = First wiimote
1 = Second wiimote
2 = Third wiimote
3 = Fourth wiimote

Ah! That makes sense and works perfectly now, thanks!