x


rotation script in unity

Ive just started using unity and have been trying to make a 2.5d sidescroller,i need help to make a platform rotate 90 degrees verticaly and then back....i would realy like to know how to do this...please help :)

more ▼

asked Oct 26, 2010 at 08:43 AM

shaun lamminga gravatar image

shaun lamminga
34 22 16 19

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

3 answers: sort voted first

Transform.Rotate() will rotate the platform around its midpoint. If you want to rotate around another point such as the edge, you'll need Transform.RotateAround() instead. With a little fiddling you should be able to figure out the vectors that work best for you, eg Vector3.forward or Vector3.left.

more ▼

answered Oct 26, 2010 at 09:21 AM

Ostagar gravatar image

Ostagar
166 4 5 13

Thanx ive been trying it .... how would you write up a script for the platform... i think im doing somthing wrong

Oct 26, 2010 at 11:53 AM shaun lamminga

Hey thanx im really getting somewhere with the link you gave me ... all i need is you to edit my code so that it stops at 90 degrees for three seconds and then turns back.... sorry im not very experienced at all and you obviosly know what your doing... your help would be greatly appretiated

i will post my code up as an answere

Oct 28, 2010 at 12:25 PM shaun lamminga
(comments are locked)
10|3000 characters needed characters left

var right = true;

function Update () {

if (right) { rotation = 100.0; transform.Rotate (0,0,rotation * Time.deltaTime); }

}

more ▼

answered Oct 28, 2010 at 12:29 PM

shaun lamminga gravatar image

shaun lamminga
34 22 16 19

this is how i got it to rotate continuously.

Oct 28, 2010 at 12:29 PM shaun lamminga
(comments are locked)
10|3000 characters needed characters left

Thanx ive been trying it .... how would you write up a script for the platform... i think im doing somthing wrong

more ▼

answered Oct 26, 2010 at 11:24 AM

shaun lamminga gravatar image

shaun lamminga
34 22 16 19

I have working code using these function, but there's working code and an explanation of the parameters in the Unity documentation pages already. In case you didn't spot those yet, they're at http://unity3d.com/support/documentation/ScriptReference/index.html. If that doesn't make things clearer, if you could post an example of what you tried and why that wasn't working for you, we could help you better. Cheers. :)

Oct 26, 2010 at 04:06 PM Ostagar

thanx for the comment and the link although im kinda geting to know vectors i still have no idea of how to do this or use the transform script ... an example would help alot

Oct 27, 2010 at 07:55 AM shaun lamminga
(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:

x9228
x3762
x2219
x1180
x152

asked: Oct 26, 2010 at 08:43 AM

Seen: 3129 times

Last Updated: Oct 26, 2010 at 09:25 AM