- Home /
how to make OnMouseDown() and OnMouseUp() work on ipad?
this is my code, it can work on unity 3D, but when i depoly it on ipad, it can not work. how to change it? help, thanks
function OnMouseDown() { if (transform.position.y < 1.25) { // Only pick up coin if below this height rigidbody.isKinematic = true; clicked = true; mouseCursor.gameObject.audio.Play(); var startPosition = transform.position; var moveStartTime = Time.time; raycastArea.active = true;
// Raise coin up
fromRotation = transform.rotation;
while (transform.position.y < .5) {
transform.position.y += Time.deltaTime * pickupSpeed;
// Also move it to the exact position defined by the mouse click position over time
// Otherwise there's a bit of a jump unless you click on the exact center of the coin
transform.position.x = Mathf.Lerp(startPosition.x, CursorControl.handPos.x, (Time.time-moveStartTime) * pickupSpeed);
transform.position.z = Mathf.Lerp(startPosition.z, CursorControl.handPos.z, (Time.time-moveStartTime) * pickupSpeed);
yield;
}
// Get a starting reference for the rotation slerp, so (Time.time-startTime) starts out near 0
startTime = Time.time;
while (transform.position.y < 1.1) {
transform.position.y += Time.deltaTime * pickupSpeed;
transform.position.x = Mathf.Lerp(startPosition.x, CursorControl.handPos.x, (Time.time-moveStartTime) * pickupSpeed);
transform.position.z = Mathf.Lerp(startPosition.z, CursorControl.handPos.z, (Time.time-moveStartTime) * pickupSpeed);
yield;
}
}
}
Comment
Answer by syclamoth · Oct 04, 2011 at 12:40 PM
Short answer- You don't.
Long answer- Instead you can use Input.GetTouch!