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