x


How to rotate an object without showing the underside?

Hello,

I´m rotating an object in iOS (on touch) through the following code:

function Update () {

if (Input.touchCount == 1) { var touch : Touch = Input.GetTouch(0);

if (touch.phase == TouchPhase.Moved) {

h = horizontalSpeed * touch.deltaPosition.x; transform.Rotate(0, -h, 0, Space.World); v = verticalSpeed * touch.deltaPosition.y; transform.Rotate(v, 0, 0, Space.World); } } }

How do I change this so that the underside of the object is never shown?

more ▼

asked Aug 13 '12 at 03:48 PM

cekk gravatar image

cekk
1 1

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

1 answer: sort voted first

you need to define bounds for the value

somthing like

h = horizontalSpeed * touch.deltaPosition.x;

if(h>0 && themodel.transform.eulerangels.y <90) { transform.Rotate(0, -h, 0, Space.World);

}

you only need to do this for the y value

more ▼

answered Aug 13 '12 at 06:23 PM

sfc.itzhak gravatar image

sfc.itzhak
106 1 1

Thanks I tried this but then I couldn't rotate horizontally, only vertically which meant that bottom side can be seen. I tried changing it to if(v>0 && transform.eulerAngles.x <90) { transform.Rotate(v, 0, 0, Space.World); but this doesn't work either. I can still see the bottom side of the object when I rotate.

Aug 14 '12 at 04:15 AM cekk

change the angles to match you limits. dose it limit the rotating?

Aug 15 '12 at 09:03 AM sfc.itzhak
(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:

x2026
x2013

asked: Aug 13 '12 at 03:48 PM

Seen: 185 times

Last Updated: Aug 15 '12 at 09:03 AM