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!