2017-02-21 23 views
1

привет всем, что я ошибаюсь, что на самом деле я этого не понимаю, потому что я все еще новичок в разработке игр. Я использую единство и работаю над Kinect 360 - это версия 1, я создаю новую сцену и работаю над 2D-пространством, также создаю кнопку пользовательского интерфейса в центре сцены и еще одну кнопку пользовательского интерфейса, но я изменяю ее как маленький круг, и я назвал это курсор теперь я хочу, чтобы переместить курсор с правой рукой пожеланием обнаружит на Kinect так я падаю в этом желании ошибки вКак svove transform.position присваивать попытку для недействительно

{ 
transform.position assign attempt for 'cursor' is not valid .Input position is{-Infinity,-777756757673984982383290000000000000000000000,0,0} 
} 

мой код здесь

void Update() { 

     KinectManager manager = KinectManager.Instance; 

     if (DepthImageViewer.Instance.jointColliders != null) 
     { 
      if (!isInited) 
      { 
       isInited = true; 
       initialPosition = new Vector2((DepthImageViewer.Instance.jointColliders[11].transform.position.x + 50) * 19.2f, (DepthImageViewer.Instance.jointColliders[11].transform.position.y + 50) * 10.8f);//, DepthImageViewer.Instance.jointColliders[11].transform.position.z); 
      } 

      Vector2 newPos = new Vector2((DepthImageViewer.Instance.jointColliders[11].transform.position.x + 50) * 19.2f - offstX, (DepthImageViewer.Instance.jointColliders[11].transform.position.y + 50) * 10.8f - offstY) - initialPosition;//, DepthImageViewer.Instance.jointColliders[11].transform.position.z) - initialPosition; 
      Debug.Log(DepthImageViewer.Instance.jointColliders[11].transform.position); 
     } 
     else 
     { 
      Debug.Log("not joint colliders"); 
     } 
    }  

ответ

0

Привет всем Я нашел раствор это

public int offstX= 937; 
public int offstY= 520; 

bool isInited=false; 
void Update() { 

    uint playerID; 
    if(manager != null){ 
     playerID = manager.GetPlayer1ID(); 
    }else{ playerID = 0; } 

    if(playerID <= 0) { 
     //reset all the position to the initial values 
     if (transform.position != initialPosition) { 
      transform.position = initialPosition; 
     } 
     //reset all the rotation to the initial values 
     if (transform.rotation != initialRotation) 
     { 
      transform.rotation = initialRotation; 
     } 
     for (int i = 0; i < bones.Length; i++) 
     { 
      bones[i].gameObject.SetActive(true); 
      bones[i].transform.localPosition = Vector3.zero; 
      bones[i].transform.localRotation = Quaternion.identity; 
      if (SkeletonLine) 
      { 
       lines[i].gameObject.SetActive(false); 
      } 
     } 
     return; 
    } 
    //set the user position in space 
    Vector3 positionPointMan = manager.GetUserPosition(playerID); 
    */ 
    float initialXposition = transform.localPosition.x; 
    float initialYposition = transform.localPosition.y; 
    float nextXposition=0; 
    float nextYposition=0; 
    KinectManager manager = KinectManager.Instance; // call the Kinect instance 

    if (DepthImageViewer.Instance.jointColliders != null) 
    { 
     if (manager.Player1Calibrated && isInited == false) 
     { 
      isInited = true; 
      Debug.Log("Kinect See Your hand"); 
      transform.localPosition = new Vector2(0, 0); 
      nextXposition = transform.localPosition.x; 
      nextYposition = transform.localPosition.y; 
      if (initialXposition != nextXposition && initialYposition != nextYposition) 
      { 
       Debug.Log("I moved the cursor the the initial pisition"); 
      } 
      else 
       Debug.Log("Sorry I didn't translate the cursor"); 
     } else if (manager.Player1Calibrated && isInited == true) 
     { 
      float XvalueAre = DepthImageViewer.Instance.jointColliders[11].transform.localPosition.x * 192.0f + 184430.4f; 
      float YvalueAre = DepthImageViewer.Instance.jointColliders[11].transform.localPosition.y *108.0f + 58832.1f; 


     Vector2 newPos = new Vector2(XvalueAre - offstX, YvalueAre - offstY);// - initialPosition ,DepthImageViewer.Instance.jointColliders[11].transform.position.z) - initialPosition; 
      Debug.Log("Your Hand X position => " + DepthImageViewer.Instance.jointColliders[11].transform.localPosition.x); 
      Debug.Log("Your Hand Y position => " + DepthImageViewer.Instance.jointColliders[11].transform.localPosition.y); 
      Debug.Log("Your Converted Hand X position => " + XvalueAre); 
      Debug.Log("Your Converted Hand Y position => " + YvalueAre); 
      transform.position = newPos; 

     } 





    } 
    else 
     Debug.Log("Erreur remplir joints colliders "); 

}