ゲームエンジンのUNITYを使用して作成しています 開発はボッチで行っています(寂しくなんかないもん)
プログラミングと簡単なモデリングしかできないため、その他は素材を最大限利用させてもらっています 逆に言えば素材があるので1人でも、出来てしまえる時代になったということですね
2019年から開発し、100回以上バージョンアップを繰り返していました
UNITYで開発、アセットを大量に使用しています
スライダーポテンショメータモジュールというパーツが世の中にはあって それを使えばもっと簡単に実装はできたのですが、余り物があったので 光学距離センサーで実装しています。
今回ちっこいのを作りましたが、これならアニメの様にデカいのも作れそうです。
ちなみにマウスホイールの代わりとしても使用できます
パーツを組み合わせて最強の宇宙戦艦を作ることにこだわっています パーツ数は100を超え、自由にカスタマイズできます
試用も出来ますので、試しに遊んでみてください
宇宙船と言えばエンジン出力をこんな感じでコントロールするイメージですよね
「エンジン全開!」とか言いながらスロットルを開ければ気分は宇宙海賊王!
(はずいので実際には言いませんよ?)
そこで、ゲーム用に作りました。
仕組みは
光学距離センサーでハンドルまでの距離を計って、arduino leonardoでPCにマウスホイールの情報として送信します。
距離に応じてテープLEDを光らせます
SFだとフラットなキーボードで、打つと光るのを使っていますよね 宇宙船オペレーターが操作するやつ
そこで、ゲーム用に作りました
触れるとメッチャ明るく光って、ゲーム上で武器が発射されます
仕組みは
静電容量を計測して、スイッチングし
LEDをアニメーションさせています
PCにテンキーとして送り、ゲーム側で発射などを行います
機能切り替えボタンもつけ、「片手デバイス」と呼ばれる機能も使えるようにしてあります
ワンタッチでPCをスリープにしたり出来て便利!
#include <Keyboard.h>
#include "Mouse.h"
#include <CapacitiveSensor.h>
#include <Adafruit_NeoPixel.h>
#define PIN 10 // On Trinket or Gemma, suggest changing this to 1
#define NUMPIXELS 7// 10 // Popular NeoPixel ring size
#define CAP 10
const int LED_PIN = 13;
const int KANDO = 400;
const int SLIDE = A3;
int range = 5; // output range of X or Y movement; affects movement speed
int responseDelay = 10; // response delay of the mouse, in ms
float scrollUpDownOld;
float addScrool;
CapacitiveSensor cs_4 = CapacitiveSensor(8,9); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor cs_3 = CapacitiveSensor(6,7); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor cs_2 = CapacitiveSensor(4,5); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor cs_1 = CapacitiveSensor(2,3); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
pinMode(SLIDE, INPUT);
Keyboard.begin();
pinMode( LED_PIN, OUTPUT );
cs_1.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
cs_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
cs_3.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
cs_4.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
pixels.clear(); // Set all pixel colors to 'off'
for(int i=0; i<NUMPIXELS; i++)
{
pixels.setPixelColor(i, pixels.Color(0, 0, 0));
}
pixels.show(); // Send the updated pixel colors to the hardware.
}
void Pass(String u, String p) {
Keyboard.print(u); //ID
Keyboard.write(KEY_TAB);
delay(100);
Keyboard.print(p); //password
Keyboard.write(KEY_TAB);
Keyboard.write(KEY_RETURN);
delay(2000);
}
void Pass2(String p) {
int i;
p += "#";
for(i=0; i<p.length(); i++){
Keyboard.print(p.substring(i, i + 1));
delay(0);
}
Keyboard.write(KEY_RETURN);
delay(500);
}
unsigned long lapTime;
unsigned long startTime;
int rpmCount;
bool rpmFlag;
bool flag;
#define A0 3//光
int r[NUMPIXELS] = {10,10,0,0,0,60,60};
int g[NUMPIXELS] = {10,10,30,30,30,0,0};
int b[NUMPIXELS] = {0,0,5,5,5,0,0};
unsigned long leddownTime;
void loop() {
long key1 = cs_1.capacitiveSensor(CAP);
#if DEBUG
Serial.print(key1); // print sensor output 1
Serial.print(" ");
#endif
if (key1 > KANDO)
{
digitalWrite( LED_PIN, LOW );
// スリープ
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('x');
delay(100);
Keyboard.releaseAll();
delay(100);
Keyboard.write('u');
delay(100);
Keyboard.write('s');
delay(300);
}
long key2 = cs_2.capacitiveSensor(CAP);
#if DEBUG
Serial.print(key2); // print sensor output 1
Serial.print(" ");
#endif
if (key2 > KANDO)
{
digitalWrite( LED_PIN, LOW );
// CTRL-F
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press('f');
delay(100);
Keyboard.releaseAll();
delay(300);
}
long key3 = cs_3.capacitiveSensor(CAP);
#if DEBUG
Serial.print(key3); // print sensor output 1
Serial.print(" ");
#endif
if (key3 > KANDO)
{
//パスワード等入力
Keyboard.print("12345");
Keyboard.write(KEY_RETURN);
digitalWrite( LED_PIN, LOW );
delay(2000);
}
long key4 = cs_4.capacitiveSensor(CAP);
#if DEBUG
Serial.print(key4); // print sensor output 1
Serial.print(" ");
#endif
if (key4 > KANDO)
{
//よく使うアプリケーションの起動
digitalWrite( LED_PIN, LOW );
Keyboard.press(KEY_LEFT_GUI); // ファイル名を指定して実行の起動
Keyboard.press('r');
Keyboard.releaseAll();
delay(120);
Keyboard.print("C'/tmp/1.lnk"); // ペイント起動 @D'/Program Files/sakura/sakura@
Keyboard.write(KEY_RETURN);
delay(100);
//USキーボード変換
//https://sites.google.com/site/gutugutu30/other/arduinoleonardodegaizaoshitatenkiwozifenzhuanyongnomononisuru
Keyboard.press(KEY_LEFT_GUI); // ファイル名を指定して実行の起動
Keyboard.press('r');
Keyboard.releaseAll();
delay(120);
Keyboard.print("C'/tmp/2.lnk"); // ペイント起動 @D'/Program Files/sakura/sakura@
Keyboard.write(KEY_RETURN);
delay(100);
Keyboard.press(KEY_LEFT_GUI); // ファイル名を指定して実行の起動
Keyboard.press('r');
Keyboard.releaseAll();
delay(120);
Keyboard.print("C'/tmp/3.lnk");
Keyboard.write(KEY_RETURN);
delay(3000);
}
float scrollUpDown = analogRead(SLIDE);
#if DEBUG
Serial.print(" "); // print sensor output 1
Serial.print(scrollUpDown);
Serial.print(" "); // print sensor output 1
#endif
scrollUpDown = (scrollUpDown * 1 + scrollUpDownOld *9)/30;
pixels.clear(); // Set all pixel colors to 'off'
if(leddownTime > millis())
{
for(int i=0; i<NUMPIXELS -(scrollUpDown+3)/5 && i<NUMPIXELS; i++)
{
pixels.setPixelColor(NUMPIXELS -i -1, pixels.Color(r[i], g[i], b[i]));
}
}
pixels.show(); // Send the updated pixel colors to the hardware.
#if DEBUG
Serial.println(scrollUpDown);
#endif
addScrool += -(scrollUpDown - scrollUpDownOld);
//感あり
if(abs(addScrool) >= 0.3)
{
leddownTime = millis()+3000;
if(lapTime < millis()){ //abs(scrollUpDown - scrollUpDownOld) < 0.3 &&
//float a = abs(scrollUpDown - scrollUpDownOld);
//Serial.println(addScrool);
Mouse.move(0,0, addScrool*3);
addScrool = 0;
//addScrool /= 1.09;//(a/100);
lapTime = millis() +30;
}
}
scrollUpDownOld = scrollUpDown;
}