2017-02-21 5 views
1

안녕하세요 여러분 모두 제가 잘못 이해하고 있습니다. 게임을 개발하는 초급자이기 때문에 이해가 안됩니다. Kinect 360을 사용하여 Kinect 360을 버전 1로 만들고 새로운 장면을 만들고 2D 공간에서 작업 중이며 장면 중심과 다른 UI 버튼에 UI 버튼을 만들지 만 작은 원으로 수정하고 이름을 지정했습니다. 지금 나는 내가 그 오류 소원에 빠지게 넥트 에 의해 감지 내 오른쪽 소원으로 커서를 이동어떻게 슬라브 변형. 위치 할당 시도가 유효하지 않습니다.

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

}