Hi,
I’m working on FPS game and there’s a crosshair(and it’s texture) on the screen. Now I need to move it with touch and drag. I have already searched through forums but nothing helps for me. Here’s my method:
protected void processMove(Vector3 delta)
{
#if UNITY_ANDROID || UNITY_IPHONE
if (Input.touchCount > 0)
{
if (Input.GetTouch(0).phase == TouchPhase.Began)
{
var t = Input.GetTouch(0);
touchId = t.fingerId;
startTouchPos = t.position;
}
var touch = Input.GetTouch(touchId);
if(touch.phase == TouchPhase.Moved)
{
var x = touch.deltaPosition.x * Time.deltaTime * 10f;
var y = touch.deltaPosition.y * Time.deltaTime * 10f;
//var dest = Camera.main.ScreenToWorldPoint(
//new Vector3(startTouchPos.x, startTouchPos.y, 1000));
crosshairPosition = new Rect(x, y, crosshairTexture.width, crosshairTexture.height);
}
}
#endif
}
I’m calling this method in Update(). What am I doing wrong?
Thank you.