- Home /
transform RotateAround
I was just playing around with RotateAround function and i have a doubt regarding the first parameter i.e. point : Vector3
.
I tried snippets of code like :
1)transform.RotateAround(Vector3.right * 10, Vector3.right, Time.deltaTime * 10);
2)transform.RotateAround(Vector3.up * 10, Vector3.right, Time.deltaTime * 10);
I didn't seem to understand anything apart from the cube rotating and revolving.
Does Vector3.right * 10
mean position multiplied by 10 units in 'x' direction ?
I added another cube as a target cube and rotated around its position. Then the cube was revolving around the target as well as rotating which was pretty much what i expected.
Can anyone explain what is happening in the 2 code snippets i have written above ?
Thanks, Adithya.
what does Vector3.right * 10 do then ? I was under the impression that the cube would move 10 units towards x-axis and rotate around x-axis. So, if the initial position is Vector3(0,0,0) the cube would move to Vector3(10,0,0) and rotate around x-axis if i said :
transform.RotateAround(Vector3.right 10, Vector3.right, Time.deltaTime 10);
It would be great if someone clarified my doubt ..
transform.RotateAround is different from transform.Rotate ... first one will change the object and move it to another point... but transform.Rotate is for rotating... use it and u will get it...
Answer by MobinS · Jun 06, 2012 at 08:51 AM
well i didn't get what you really mean , but as i get 50% of it , when you write this line every object in the screen or game level spin... if this script doesn't work (by any problem) that's because you don't use it in a correct place... first of all read the manual of this function then use it ... as you see :
"Rotates the transform about axis passing through point in world coordinates by angle degrees. This modifies both the position and the rotation of the transform. "
as you see you should use other functions... if you want your object rotate in one axis then use Transform.Rotate ... for example if you want to spin the object that the script is attached to to x axis multiplied by 10 then use this script :
transform.Rotate(Vector3.right *10 * Time.deltaTime);
hope that will solve ur problem.. good luck ;) Mobin Shakeri
Your answer
Follow this Question
Related Questions
Rotate Around an Object using a different pivot point? 0 Answers
Why am I getting 2 different results with RotateAround? Trying to move cubes on surface of sphere. 0 Answers
transform.rotate only 1 time for 180 degrees? 1 Answer
how to rotate game-Object in a fixed position 1 Answer
rotation script in unity 3 Answers