• 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 Edyvargas · Sep 02, 2014 at 02:03 AM · axissphereplanet

Rotation Script Changes the Object Axis Inclination Too

Hi Everyone,

I have a rotation script for the rotation of a planet (The Earth) but the planet has a 23,67 inclination degrees on its own axis (on the Y rotation vector of the Sphere Object), and the rotation script works fine at any speed until i give the planet object its proper inclination degrees, then , when i change the speed of the rotation, the sphere wont mantain its correct axis and change its inclination, this is the script:

 var rotationSpeed: float = 15;
 
 function Update() {        
 
 // planet to spin on it's own axis 
 transform.Rotate(transform.up * rotationSpeed * Time.deltaTime, Space.World);
 
 }

Thanks to any Help :)!

Comment

People who like this

0 Show 3
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 SaxonHammer · Sep 02, 2014 at 02:09 AM 0
Share

You have used Space.World in the rotation so that transform.up now means world space up ie the Y axis

avatar image Edyvargas · Sep 02, 2014 at 02:13 AM 0
Share

Hi, thanks for the fast answer!, but when i put "Space.Self" instead, it gets crazy and rotates everywhere....

avatar image Edyvargas · Sep 02, 2014 at 03:07 AM 0
Share

...Interesting, when i use transform.right instead of transform.up in the script, the object rotates well on its own center at any speed, dont know why....

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Edyvargas · Sep 02, 2014 at 04:33 AM

SOLVED!, in the first code i changed transform.up for Vector3.up, and its working great now, thanks and hope this helps to anybody with a similar issue, the working code its this:

var rotationSpeed: float = 15;

function Update() {

transform.Rotate(Vector3.up rotationSpeed Time.deltaTime, Space.World);

}

Comment
hb20007

People who like this

1 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 Edyvargas · Sep 02, 2014 at 02:58 AM

I found that using the RotateBehaviour.cs script from the Standard Assets, the sphere object rotates fine on its own pivot center even after of being tilted some degrees, but i need to use it in the javascript code, any idea? thank you:

 using UnityEngine;
 using System.Collections;
 
 //Decompile by Si Borokokok
 
 public class RotateBehaviour : MonoBehaviour
 {
     public Vector3 RotationAmount;
 
     private void Update()
     {
         transform.Rotate((Vector3) (RotationAmount * Time.deltaTime));
     }
 }
 
 
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

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

23 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

Related Questions

planetary level of detail system (cubesphere) 0 Answers

How to place objects from a 2d plane around a sphere? 1 Answer

How to create a terrain in a sphere with Perlin Noise 0 Answers

Is it possible to generate a high-poly spherical model from a mercator-projection heightmap? 1 Answer

how to control the horizontal position of object in a 4 units wide plane? 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