Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
1
Question by srcn · Apr 29, 2012 at 12:38 AM · rotationobjectrotatedegrees

How can I rotate an object with certain degrees?

I tried to rotate using;

 Object.gameObject.transform.Rotate(new Vector(x,y,z));

and

 Object.gameObject.transform.Rotate(x,y,z);

but whenever I use them object keeps rotating?

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 Fabkins · Apr 29, 2012 at 12:49 AM 0
Share

Are you calling those in an Update()?

avatar image srcn · Apr 29, 2012 at 02:05 AM 0
Share

yep, in update()

2 Replies

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

Answer by kolban · Apr 29, 2012 at 01:34 AM

Every time you execute the transform.Rotate() method, the object will rotate by the degrees around the given axis either in World or Local space. See the following manual page:

http://unity3d.com/support/documentation/ScriptReference/Transform.Rotate.html

The rotation will occur each and every time you call the function/method. If you are calling it within an Update() function, then it will rotate each and every frame. If you are not calling these statements directly in an Update check that you aren't calling them in a function which is itself called during the Update function. If you still are finding that the object is rotating and you are sure that you are not in an Update(), comment out the Rotate commands with the "//" comment code and run again. See if the object continues to rotate. It may be you have an animation associated with your object which automatically plays which includes rotation and the rotation has nothing to do with these exact statements.

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 srcn · Apr 29, 2012 at 02:20 AM 0
Share

I am trying to strech my knowledge about unity and c# script so wanted to create a simple cannon fight ai, so i wanted enemy cannon to have proper angle to hit player according to the distance between them. I thougt it must be done in Update() need to calculate the values dinamicly. I shall use a rotation function somehow then.

avatar image
0

Answer by ProfArithmetic · Apr 29, 2012 at 02:51 AM

Rotate_flag = false; if(Rotate_flag) // rotate

That should do it. And then just change the flag whenever you want it to rotate

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

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.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

Get object rotation for x axis in degrees (360) 1 Answer

What is the most efficient way to rotate an object? 3 Answers

How to rotate object slowly on only Z axis 2 Answers

Rotation with multiple objects 1 Answer

Rotate a moving object 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