2017-02-21 1 views
1

Hallo an alle ich fälle in Irrtum, dass ich wirklich nicht verstehe, dass, weil ich noch Anfänger in Spiel Entwicklung bin. Ich benutze die Einheit und die Arbeit an Kinect 360 ist die Version 1, ich create neue Szene und arbeite an 2D-Raum auch ich UI-Taste in der Szene-Center und eine andere UI-Taste, aber ich modifiziere es zu kleinen Kreis und ich benannt es Cursor jetzt möchte ich den Cursor mit der rechten Hand Wunsch von Kinect bewegen erkennt so falle ich in diesem Fehler Wunsch istWie slove transform.position assign Versuch ist, ist nicht gültig

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

mein Code hier

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"); 
     } 
    }  

Antwort

0

Hallo allerseits fand ich die Lösung ist es

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 "); 

}