Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
This question was closed Jan 18, 2016 at 11:45 AM by Chuck95 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Chuck95 · Jan 16, 2016 at 11:32 AM · rotate

How rotate diagonally a cube

Hi, i'm a beginner. How can i rotate my cube diagonally?

Comment
Add comment
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

2 Replies

  • Sort: 
avatar image
1

Answer by Dudicus · Jan 17, 2016 at 03:37 AM

Rotate the X axis and the Z axis at the same speed. That should work!

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 Chuck95 · Jan 18, 2016 at 11:44 AM 0
Share

Great @Dudicus ! if i move the cube in a specific position and rotate X and Z axis it works! thanks!

avatar image
0

Answer by hexagonius · Jan 16, 2016 at 01:18 PM

Rotation always happens around an axis. usually you rotate around x, y or z axis. In your case, you use a diagonal axis like

 new Vector3(1,1,1);

which points into the upper forward right corner. Use it like this:

 transform.Rotate(Vector3.one * Time.deltaTime);

where Vector3.one is shorthand for a Vector3(1,1,1);

Rotate has a last default parameter which is set to Space.Self, which means it does not matter how the cube is rotated in the first place, the rotation stays the same relative to that cube.

Comment
Add comment · Show 4 · 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 Chuck95 · Jan 16, 2016 at 01:33 PM 0
Share

thanks @hexagonius for the comment but i don't understand, here is my code private Vector3 V = new Vector3(10, 10, 10); void Update() { transform.Rotate(V * Time.deltaTime);} but the cube does not rotate diagonally

avatar image hexagonius Chuck95 · Jan 16, 2016 at 07:36 PM 0
Share

And what is it doing? I mean the rotation is not spot on perfect, but in my scene it IS rotating diagonally (C# though):

 using UnityEngine;
 using System.Collections;
 
 public class Rotator : $$anonymous$$onoBehaviour {
 
     Vector3 V = new Vector3(10,10,10);
     
     // Update is called once per frame
     void Update () {
         transform.Rotate(V * Time.deltaTime);
     }
 }

avatar image Chuck95 hexagonius · Jan 16, 2016 at 09:59 PM 0
Share

@hexagonius i'm sorry but this is not what i mean; alt text

this is my cube and i want that his rotation is only on the diagonal of the square! I'm sorry if i can't explain very well! :)

cattura.jpg (14.4 kB)
Show more comments

Follow this Question

Answers Answers and Comments

38 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 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

vector3 rotatetowards don't work 1 Answer

angle add constant at vector3 1 Answer

Roatate object to player on tag 0 Answers

How to Rotate on Y Axis by 90 degrees left or right? 1 Answer

it is possible to rotate a texture ? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges