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 /
avatar image
0
Question by Rise2 · Feb 05, 2018 at 08:20 PM · rotationz-axistranslationasteroidsasteroid

Sprite rotation (z-axis) and translation (y) is not working

Hello everyone,

I have this game with asteroids, and I want my asteroids to rotate on the z-axis while going down with a y translation. Instead, the asteroids rotate slowly as they move in a circle towards the right.

Here is what's happening in an image:alt text

Here is the code that gives me this result:

     public GameObject asteroid;
 
     public float speedZ;
     public float speedDown;
 
     void Update()
     {
 
         transform.Rotate(Vector3.forward * Time.deltaTime * speedZ);
 
         transform.Translate(Vector3.down * Time.deltaTime * speedDown);
 
         if (asteroid.transform.position.y < -5.5f)
         {
             Destroy(asteroid);
         }
     }

The value I am using at the moment for speedZ is 20, and for speedDown, 1,5.

The more the value of speedZ goes up, the more the circle in which the asteroid moves gets smaller. This can be seen in the following image where the asteroids have bunched up in a tight circle at a speedZ of 90: alt text

Any help to solve this problem is greatly appreciated, Thank you in advance.

situation.png (8.3 kB)
asteroidcircle.png (28.4 kB)
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
1

Answer by Timo326 · Feb 05, 2018 at 09:02 PM

Use Space.World in the translation as second parameter:

 transform.Translate(Vector3.down * Time.deltaTime * speedDown, Space.World);
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 Rise2 · Feb 05, 2018 at 09:41 PM 0
Share

Wow, it works, thank you so much!

avatar image Timo326 Rise2 · Feb 05, 2018 at 09:46 PM 0
Share

Nice to hear :-)

avatar image Rise2 · Feb 05, 2018 at 10:15 PM 0
Share

I feel so dumb, but thanks, you saved me plenty of hours of knocking my head on my desk!

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

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

How do I rotate player's camera to peak around objects. (first person shooter leaning) 1 Answer

How to rotate a gameObject towards a hit point along Z axis? 1 Answer

[2D] Player's arm following the mouse 1 Answer

Translate and rotate at the sametime problem 1 Answer

Move object forward relatively to itself 3 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