見出し画像

【技術解説】Ninja Game (make game with Switch Joycon)

Hi, I am interaction engineer/designer MAO (@rainage) of The Designium.
In this article, I ’m going to introduce the game we are trying to develop with a Switch Joycon.

はじめに

The Ninja Game is a R&D prototype to try some potential features of joycon.

We already make Running Game with Switch joycon console on Unity. We use accelerometer of joycon to calculate the speed of running in place and support 4 joycon connections.

技術紹介

The joycon control on Unity which we used is based on JoyconLib of Looking-Glass. (We fixed some script for multi consoles and visualization)

Before using joycon on Unity, you need to pair joycon with computer via bluetooth. Then import the JoyconLib, you can use joycon as HID device on Unity.

The basic paired steps and how to use on Unity:

画像1

The target testing functions of this prototype game are following:

- get [IMU data] then convert to object rotation
- detect [stick] value changed as shooting event
- set [rumble] feedback when shooting

The main issues of this testing is IMU data issue:

(1) joycon visualization and fixed the invert of Y-axis:
- change joycon.cs of Looking-Glass packages

public Quaternion GetVector()
{
       Vector3 v1 = new Vector3(j_b.x, i_b.x, k_b.x);
       Vector3 v2 = new Vector3(j_b.z, i_b.z, k_b.z);
       if (v2 != Vector3.zero){
		    return Quaternion.LookRotation(v1, v2);
       }else{
           return Quaternion.identity;
       }
}

- and fixed the vector update method when you use the IMU data

orientation = joycon.GetVector();
orientation = new Quaternion(orientation.x, -orientation.z, orientation.y, -orientation.w);
targetRotation = Quaternion.Inverse(orientation);

(2) and the Y-axis rotation shift problem of IMU data

After get the rotation quaternion, you will find the Y-axis rotation value will increase with time. So I need to do re-center when it shifts a lot. It is big problem if you need to use this console for exhibition.

I tried a lot methods to solve this issue. Finally, I found it is not script problem, it is hardware problem. You only need to calibration Gyro. The easiest way is plug the joycon on your switch, then do Gyro calibration in setting.

編集後記

新人広報のマリコです!今回はインタラクションデザイナーのMao「Ninja Game」の技術解説をして貰いました!英語による解説ですが、動画やコードをつかった説明はエンジニアの方にはわかりやすかったかなと思いますが、いかがでしょうか?
Maoがこのゲームを開発したキッカケは、解説のビデオでも上手に手裏剣を投げているMaoの娘さんが”忍者マスター”になって遊ぶのが大好きだからなんだそうです✨一生懸命、手裏剣を投げてる後ろ姿が可愛いですね😊最近のデザイニウムはR&Dが盛んで、面白いものをつくってどんどん公開しているので、デザイニウムR&D部のマガジンも是非チェックしてくださいね!

デザイニウム公式
インタラクティブサイト
Twitter
Facebook

この記事が気に入ったらサポートをしてみませんか?