x


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;
    }
}

}

more ▼

asked Oct 04 '11 at 12:39 PM

sally gravatar image

sally
-4 2 2 2

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Short answer- You don't.

Long answer- Instead you can use Input.GetTouch!

more ▼

answered Oct 04 '11 at 12:40 PM

syclamoth gravatar image

syclamoth
15k 7 15 80

Any more suggestion

Oct 05 '11 at 01:37 AM sally
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x33

asked: Oct 04 '11 at 12:39 PM

Seen: 1164 times

Last Updated: Oct 05 '11 at 01:56 AM