x


Rotate Object Via GUI

What is the best way to rotate an object (on the z axis) with a GUI component? I am making a kind of sandbox/create style game, and for scaling, I used a horizontalslider by setting the objects localscale.

more ▼

asked Mar 19 '11 at 07:44 PM

Xedfire 1 gravatar image

Xedfire 1
158 13 14 23

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

2 answers: sort voted first

It's really up to you, or you could google studies on user interaction and usability. You could use a slider for that, or a couple of buttons (rotate counterclockwise, rotate anti-counterclockwise), or detect a drag on the object itself.

more ▼

answered Mar 19 '11 at 08:17 PM

DaveA gravatar image

DaveA
26.4k 151 171 256

Thanks for the quick response! I think that I will use another horizontal slider, just to go with the flow of things. But when I tried to do this before, it was very buggy, and only worked if I called the objects transform.rotation. What should I do?

Mar 19 '11 at 10:32 PM Xedfire 1

Yeah you'd map the slider's value to (I'm guessing) 0 to 360 and set that to object's transform.rotation.z

Mar 20 '11 at 01:30 AM DaveA

Or use transform.Rotate() and feed it a degree, which would be applied per-frame. So send small values of essentially delta-z-rotation, then your slider would be like a 'rotate velocity'

Mar 20 '11 at 01:31 AM DaveA

yeah, I did try using 0 to 360, but it seemed that it only worked with 0 to 1. But even then it didn't rotate the object properly, and glitched when going backwards. I've just tried doing transform.Rotate(), but it doesn't work the way I'd want it to. As you said, it would be like a "rotate velocity". There is also quite a lot of lag applied because it is rotating it every frame.

Mar 20 '11 at 09:34 AM Xedfire 1

Can you edit your question to include your code?

Mar 20 '11 at 09:58 PM DaveA
(comments are locked)
10|3000 characters needed characters left

can you post your code here, because i have the same problem and don't know what to write.

more ▼

answered Oct 27 '11 at 12:32 PM

rhose87 gravatar image

rhose87
78 14 17 17

(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:

x3669
x2155
x134
x19
x2

asked: Mar 19 '11 at 07:44 PM

Seen: 1383 times

Last Updated: Oct 27 '11 at 12:32 PM