• 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
Question by PlatinumSkink · Mar 17, 2011 at 08:34 AM · rotatedirectionconstantsingle

Constant Rotation to an Object

How would I make an object constantly rotate in a single direction? This particular time being in the Z axis? For all eternity? Undisturbed forever?

Comment
BiG
NeverHopeless
secondstory
unity_bTkJGG31azdikQ
lore_m_

People who like this

5 Show 1
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 purnjay · Oct 13, 2015 at 11:30 AM 0
Share

Thanks !!! its working for my Game

6 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Ashkan_gc · Mar 17, 2011 at 08:39 AM

void Update ()
{
    transform.Rotate (0,0,50*Time.deltaTime); //rotates 50 degrees per second around z axis
}

take a look at link texttransform class and it's methods

Comment
loopyllama
robertmathew
BiG
NeverHopeless
chelder
zakirshikhli
Isovald
oussama_bonnor
Ajesus-
BojoXZ
NinetysDude
Musabbir
TractGames
secondstory
unity_bTkJGG31azdikQ
And 11 more...

People who like this

26 Show 3 · 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 zakirshikhli · Jun 21, 2016 at 11:05 AM 1
Share

Simple, Useful.

avatar image mchts · Jun 25, 2017 at 08:41 PM 0
Share

Yes but transform.Rotate lags in time. How to do it smoothly?

avatar image robotcreeper3000 mchts · Jan 18, 2022 at 07:31 AM 0
Share

change "void update" into "void FixedUpdate"

avatar image

Answer by pravin gate · Mar 17, 2011 at 09:53 AM

var degreesPerSecond : float = 50.0;

function Update() { transform.Rotate(Vector3.up degreesPerSecond Time.deltaTime, Space.Self); transform.Rotate(Vector3.left* degreesPerSecond * Time.deltaTime,Space.Self);

rigidbody.isKinematic = true;

}

you can use this one also to rotate constant speed as u want.

Comment
Zephyr-Zhang

People who like this

1 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 Sacaitha · Jul 29, 2021 at 06:09 PM 0
Share

Because you put:

rigidbody.isKinematic = true;

You made me realize I had to instead directly rotate the rigidbody, and not do so through transform.rotation. 10 years later and you helped me!

avatar image

Answer by Unamine · Mar 17, 2011 at 10:59 AM

There is a script ready in case of Lerpz which can be downloaded directly from the official site. Is the tutorial 3dplatform

Comment

People who like this

0 Show 0 · 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

Answer by RuneShiStorm · May 15, 2017 at 05:14 AM

I cant make it work :/ I just want a COG rotiation in the background. Do I have to turn this asset into a Prefab or can I just drop it on the scene and add some sort of script to make it rotate? (2D plaformer)

Comment

People who like this

0 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 ronbeech · May 17, 2017 at 06:50 PM 0
Share

I'm pretty new on this, but maybe this could work:

 public float rotateSpeed; //set it in the  inspector
 
 void Update () {
    rotate();
 }
 
 
 void rotate() {
     transform.rotate(Vector3.right, rotateSpeed * Time.deltaTime, Space.World);
 }

You may need to change .right to one of the other static variables found here: https://docs.unity3d.com/ScriptReference/Vector3.html

Hope this helps.

avatar image

Answer by MatteoGodzilla · Jan 05, 2018 at 01:22 PM

you can use this:

 void Start () {
         z = 0.5f;  //velocity
     }
     
 void Update () {
         game.transform.Rotate(new Vector3(0,0,z)); //applying rotation
     }

the transform.Rotate function is applied to the existing rotation,not to the 0 of that axis. If the object is rotated 25 degrees and you apply to the rotation 2 degrees , the result will be tilted 25+2=27 degrees

Comment

People who like this

0 Show 0 · 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
  • 1
  • 2
  • ›

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Locking onto enemies with the third person controller 2 Answers

Force and rotation 2 Answers

rotating object joystick rotation direction current object independently 0 Answers

Camera rotation around player while following. 6 Answers

Quaternion based slerp to make homing projectile doesn't turn 1 Answer


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