• 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
0
Question by saberboy117 · Jul 24, 2011 at 12:30 AM · transforms

Transform.RotateAround Pro

Iv read the doc on rotatearound and am wondering how to use it to make a sun orbit a planet, so far it wont move the object it only rotates the eulerAngles, how do I make it move as well?

 private var t : Transform;
 var RotatePoint : Vector3;
 var rotatespeed : float;
 
 function Start(){
 t = transform;
 }
 function FixedUpdate () {
 t.RotateAround(t.position + t.forward,Vector3.right,rotatespeed*Time.deltaTime);
 }
 

the point is the pos I want it moving around

thanks

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by aldonaletto · Jul 24, 2011 at 12:50 AM

You must define the point around which your object should rotate:

 t.RotateAround(RotatePoint,Vector3.right,rotatespeed*Time.deltaTime);
NOTE: It would be better if you used a Sun variable in your script and dragged the sun object to it:

private var t : Transform; var Sun : Transform; // object around which the planet should orbit var rotatespeed : float;

function Start(){ t = transform; } function FixedUpdate () { t.RotateAround(Sun.position,Vector3.right,rotatespeed*Time.deltaTime); } I'm supposing the planet should orbit the sun, and not the other way around (as you said in your question...)

Comment
Add comment · 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 saberboy117 · Jul 24, 2011 at 01:01 AM 0
Share

I did, I changed the var to (338,0,227)

avatar image saberboy117 · Jul 24, 2011 at 01:21 AM 0
Share

thanks :3 XD all my falt dident put the var in XD

avatar image aldonaletto · Jul 24, 2011 at 02:37 AM 0
Share

Is it working now? If so, please click the "check" button below the voting thumbs in my answer to mark it as correct.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How can I create a grid of transforms? 3 Answers

Gaps and overlaps between platforms in the infinite runner 0 Answers

Type casting error while instantiating. 1 Answer

How to get the inverse of a transformation matrix that has a scale of zero? 1 Answer

Relative transforms and parenting 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