Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by unity_XS71vxNf4TQPBg · Sep 24, 2020 at 09:37 AM · inputkinect

Kinect in virtual machine slow input

Hello, I'm making an application using kinect sdk for unity provided by Microsoft. I use specifically the BodySourceManager and my own script to track the right hand and the right hand state. Here is the code:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using Windows.Kinect;
 using System.Linq;
 using UnityEngine.SceneManagement;
 using UnityEngine.UI;
 
 public class DetectJoints : MonoBehaviour
 {
     
     public GameObject BodySourceManager;
     public JointType TrackedJoint;
     private BodySourceManager BodyManager;
 
     private ulong TrackingId = 0;
 
     private Body[] Bodies;
     public float multi = 10f;
 
     void Start()
     {
         if(BodySourceManager == null)
         {
             Debug.Log("Nie dodałeś");
         }
         else
         {
             BodyManager = BodySourceManager.GetComponent<BodySourceManager>();
         }
     }
     
     private void Update()
     {
             if (BodyManager == null)
             {
                 return;
             }
 
             Bodies = BodyManager.GetData();
 
             if (Bodies == null)
             {
             gameObject.GetComponent<Image>().enabled = false;
                 return;
             }
             foreach (var Body in Bodies)
             {
                 if (Body.IsTracked)
                 {
                 gameObject.GetComponent<Image>().enabled = true;
                 TrackingId = Body.TrackingId;
                 //Debug.Log(TrackingId);
                 }
                 if (Body.IsTracked && TrackingId == Body.TrackingId)
                 {
                     var pos = Body.Joints[TrackedJoint].Position;
                     Vector2 position = new Vector2(pos.X * multi, pos.Y * multi);
                     Vector2 offset = new Vector2(0,0.5f);
                     gameObject.transform.position = new Vector2(Mathf.Clamp(position.x, 1.4f, 1.4f), Mathf.Clamp(position.y, -1.4f, 0.9f)) + new Vector2(0, -4.0f);
                     if(Body.HandLeftConfidence == TrackingConfidence.High)
                     {
                         switch (Body.HandRightState)
                         {
                             case HandState.Open:
                                 gameObject.GetComponent<BoxCollider2D>().isTrigger = false;
                                 break;
 
                             case HandState.Closed:
                                 gameObject.GetComponent<BoxCollider2D>().isTrigger = true;
                                 break;
                             case HandState.Lasso:
 
                                 gameObject.GetComponent<BoxCollider2D>().isTrigger = false;
                                 break;
                             case HandState.Unknown:
                                 gameObject.GetComponent<BoxCollider2D>().isTrigger = false;
                                 break;
                             case HandState.NotTracked:
                                 gameObject.GetComponent<BoxCollider2D>().isTrigger = false;
                                 break;
                             default:
                                 gameObject.GetComponent<BoxCollider2D>().isTrigger = false;
                                 break;
                         }
                     }
                 }
             }   
     }
 }

After I get the position value from the hand I clamp the position for the ui area of the app, so the player can select one out of three options with the right hand state being closed handles the selection method by the 2d Collision.

All the time I was testing it on a normal pc but the destination for the app will be a virtual machine with passthough a gpu, usb controller and also the kinect. I managed to make that work and also there is no input delay in the kinect studio inside the virtual machine.

So I think the culprit is my clumsy code I managed to make working (I'm very new into programing sorry).

Is my code just bad?

Thanks for your help.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by unity_XS71vxNf4TQPBg · Sep 24, 2020 at 10:07 AM

This is a little confusing but when running in the background the kinect studio the apps started to work as intended... For me it isn't a problem to just run that before the app, but this isn't the way how that supposed to be working ;-;

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

167 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

How to simulate mouse input? 1 Answer

Running two Kinects on the same machine 0 Answers

Allow clickthrough UI element but still trigger OnClick 0 Answers

Multi - touch not registering during update. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges