0
我想將用戶觸摸三角洲位置轉換爲世界上的遊戲對象的三角洲位置,有沒有這樣做?統一屏幕三角洲世界三角洲
//drag
if (duringmove && (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved))
{
Debug.Log("will move " + progressTrans.gameObject.name);
endPos = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
//should convert te deltaPos here
progressTrans.localPosition += Vector3.right * Input.GetTouch(0).deltaPosition.x;
progressTrans.localPosition = new Vector3(Mathf.Clamp(progressTrans.localPosition.x, mostLeft, mostRight), progressTrans.localPosition.y, progressTrans.localPosition.z);
}
請注意,我用建設與正字模式
如果您的2D遊戲是「內部」_Screen空間 - 覆蓋_畫布,您的'Input.GetTouch(0).deltaPosition'值應該與您要應用的'localPosition' delta相同。也不知道爲什麼'endPos = [']'線在這裏? – Kardux
@Kardux感謝您的答覆,gameobject不在畫布中,endPos是爲了進一步使用。 – armnotstrong