LoginSignup
2
1

More than 5 years have passed since last update.

LeapMotionでparticleを制御する

Posted at

LeapMotionでつくるコンテンツのメモです。

LeapMotionの手の動きの取り方

スクリプトによる制御方法を知る場合,以下のドキュメントをみるほうがよいです。
https://leapmotion.github.io/UnityModules/namespaces.html
image.png
SDKがアップデートされていて,過去の記事のコードが参考にならない場合もあるのでドキュメントも目を通すといいと思います。

基本的に使うのはController,Frame,Hand,Fingerだという印象を受けました。

以下のスクリプトで,手の握った角度と強さがわかるようなので,ひとまずはこの値を使うと便利そうです。
GrabStrengthは[0,1]のfloat値で,実用上はこっちを使うほうがよさそうという印象。

   Controller controller = new Controller();
   private Frame frame;    
    void Update () {
        if (controller.Frame() != null)
        {
            frame = controller.Frame();
            foreach (Hand mhand in frame.Hands)
            {
                Debug.Log(mhand.GrabAngle+":"+mhand.GrabStrength);                
            }
        }

手を広げかたでparticleの動作を制御

  Controller controller = new Controller();
    private Frame frame;
    [SerializeField] ParticleSystem particle;
    private void Start()
    {
        particle.Stop();
    }

    void Update () {
        if (controller.Frame() != null)
        {
            frame = controller.Frame();
            foreach (Hand mhand in frame.Hands)
            {
                Debug.Log(mhand.GrabAngle+":"+mhand.GrabStrength);

                if (mhand.GrabStrength < 0.2)
                {
                    particle.Play();
                }
            }
        }

最終的に上記のようにすることでparticleの制御を手の動きでできるようにしました。

参考

  • LeapMotionプログラミングガイド
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1