You can use if (Input.touchCount == 1)
to detect more than just one finger tap (at the same time). Then you can place your object based on the two-finger touch.
// Store both touches.
Touch touchZero = Input.GetTouch(0);
Touch touchOne = Input.GetTouch(1);
// Calculate previous position
Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;
// Find the magnitude of the vector (the distance) between the touches in each frame.
float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
float touchDeltaMag = (touchZero.position - touchOne.position).magnitude;
// Find the difference in the distances between each frame.
float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;
float pinchAmount = deltaMagnitudeDiff * 0.02f * Time.deltaTime;
spawnedObject.transform.localScale -= new Vector3(pinchAmount, pinchAmount, pinchAmount);
// Clamp scale
float Min = 0.005f;
float Max = 3f;
spawnedObject.transform.localScale = new Vector3(
Mathf.Clamp(spawnedObject.transform.localScale.x, Min, Max),
Mathf.Clamp(spawnedObject.transform.localScale.y, Min, Max),
Mathf.Clamp(spawnedObject.transform.localScale.z, Min, Max)
);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…