Home>

https://qiita.com/GenkiOkuma/items/bc0469fc3b29ed2f88cf
We are currently taking the heart rate with reference to this Okuma site and reflecting it in unity.
Currently, we have arrived at the process [from ANT + USB dongle to Node.js], but an error occurred when creating js.
I'm new to js and I'm new to programmers. Please please.

Error message
Assets/StreamingAssets/Heartrate/main.js (3,6): UCE0001: ';' expected.Insert a semicolon at the end.
Assets/StreamingAssets/Heartrate/main.js (4,6): UCE0001: ';' expected.Insert a semicolon at the end.
Assets/StreamingAssets/Heartrate/main.js (5,6): UCE0001: ';' expected. Insert a semicolon at the end.</Code></pre>
<p>'</p>
<strong>Applicable source code</strong>
<pre><code>const stick = new Ant.GarminStick2 ();
const sensor = new Ant.HeartRateSensor (stick);
var deviceID = null;
if (process.argv.length>= 3) {
    deviceID = process.argv [2];
}
sensor.on ('hbData', function (data) {
    if (deviceID == null) {
        console.log (data.DeviceID, data.ComputedHeartRate);
    } else if (deviceID == data.DeviceID) {
        console.log (data.ComputedHeartRate);
    }
});
stick.on ('startup', function () {
    sensor.attach (0, 0);
});
if (! stick.open ()) {
    console.log ('Stick not found!');
}
I tried putting

;in various places. There is no response.
Probably my writing is bad (?)

Supplemental information (FW/tool version etc.)

Please provide more detailed information here.

  • Answer # 1

    (Since I didn't try it, I'm sorry if it didn't work)

    Unity used to support JavaScript in the past, and it seems that Unity is recognized by the remnant.
    Main.js is not Unity but it is something you want to run on Node.js, so it is strange when Unity recognizes it.
    In the developer's blog for running Node.js, a js script is prepared in the directory `` StreamingAssets/.node/'', not directly under StreamingAssets, so please try moving the js file there .
    (Note that the directory starting with "." Is a hidden directory on Mac, Linux, etc., and the content of the blog is valid for Unity including the Windows version, so use it)