• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by lixpoxx · Aug 13, 2013 at 11:36 AM · gameobjectrotateyxz

Rotating GameObject problem

Hey! I'm making a game for Android and i want to make coins for it. Now i have a problem. I want to have 2 cubes spinning inside a cube but they don't rotate like i want. I made a big Over-Object, that holds them together: coin 1 2 3

I want all together to rotate around the y axis and every seperate to rotate around its own z axis. here is how i mean it;D (Pain(t))here is how i mean it

skizze.png (12.0 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lixpoxx · Aug 13, 2013 at 12:46 PM 0
Share

Thanks everybody problem solved :D

lixpoxx

avatar image CHPedersen · Aug 13, 2013 at 12:48 PM 0
Share

No problem, glad you got it working. I have converted your answer to a comment as it was more suited for that. :) I've also upvoted your question since I thought it was pretty clear from the text and image what you were asking. With your new reputation, you should now be able to comment, upvote and mark as answer. Welcome to Unity Answers!

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by CHPedersen · Aug 13, 2013 at 11:40 AM

You have to write 2 different scripts: One to rotate the entire system, and one to rotate each individual coin. You could call them RotateCoinScript and RotateCoinSystemScript.

RotateCoinSystemScript would have an Update method that calls this:

     float rotationSpeed = 10;
     transform.RotateAroundLocal(Vector3.up, Time.deltaTime * rotationSpeed);

And RotateCoinSystemScript would have an Update method that calls this:

     float rotationSpeed = 10;
     transform.RotateAroundLocal(Vector3.forward, Time.deltaTime * rotationSpeed);

Then you add the RotateCoinScript to each coin (so they each have their own individual instance of it), and then the RotateCoinSystemScript to the parent object (what you call the "Over-Object").

You can adjust the rotation speed as you see fit. Note that Vector3.up is short-hand for the y vector, and Vector3.forward is the z vector. These are globally static properties that always return (0,1,0) and (0,0,1) respectively, but their use becomes local to the objects when using transform.RotateAround*Local* (as opposed to just transform.RotateAround).

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Narv · Aug 13, 2013 at 11:39 AM

ughhhhhhh....

I assume you're trying to do this in code? Since you haven't said what you're doing to solve the issue. Try making an animation for this and attach the .anim files to the coin "parts".

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Joyrider · Aug 13, 2013 at 11:42 AM

Use Transform.RotateAround for the Y (which will make them rotate around an axis in world coordinates (worldaxes don't change if your object moves)

Transform.Rotate for the Z (which will make your object rotate according to its own axes)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by lixpoxx · Aug 13, 2013 at 12:48 PM

I have made one script with the variables rotatez and rotatey.

I tryed Transform.RotateAround but the Console shows this: Assets/scripts/rotator.js(10,25): BCE0023: No appropriate version of 'UnityEngine.Transform.RotateAround' for the argument list '(int, float, int, UnityEngine.Space)' was found.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Graham-Dunnett ♦♦ · Aug 13, 2013 at 12:49 PM 0
Share

make sure the arguments you pass are all floats, and not ints.

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

y and z rotation axis doing the same thing when x is 270 degrees 0 Answers

spin only on one axis 1 Answer

How can I get x, y, z spawnpoints from a csv or text file? 1 Answer

How to create a GUI Text when reaching a point 1 Answer

I have a GUI Text that shows the X,Y,Z but im not sure how... I made one but It just kept increasing... any advice? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges