Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 nicoolsen10 · Jul 04, 2019 at 05:49 PM · objectrotating

How to make something rotate faster and faster

I have an orb in my game and it rotates 25 degrees per second from a script but I want to make so it can attack and I want it to go faster and faster after every second so it "charges" itself how would you approach that?

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 metalted · Jul 04, 2019 at 06:00 PM

Save the rotational speed to a variable, then add a certain amount to that variable every second. Apply rotation to object.

 public float originalRotationSpeed = 25f;
 public float rotationIncrement = 1f;
 public bool incrementRotation = false;
 public float currentRotationSpeed;
 
 public void Start()
 {
     ResetRotation();
 }
 
 public void ResetRotation()
 {
     currentRotationSpeed = originalRotationSpeed;
 }
 
 public void Update()
 {
     float delta = Time.deltaTime;
     transform.Rotate(0, currentRotationSpeed * delta, 0);
     
     if(incrementRotation)
     {
         currentRotationSpeed += rotationIncrement * delta;
     }
 }
     


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 nicoolsen10 · Jul 04, 2019 at 06:29 PM 0
Share

I just added it but there is one thing it doesn't look like it goes faster and faster in the rotation how do I fix that?

avatar image metalted nicoolsen10 · Jul 05, 2019 at 01:13 PM 0
Share

The script is setup as follows: The values represent the initial rotation speed and the amount to add to the rotation each second. The boolean is used to increment the rotation or not, this depends on what you need. $$anonymous$$aybe you don't want to speed up rotation right away or you want to stop increasing the rotation speed at some point. You can set the bool to true or false for that. ( If it is not increasing now, maybe it is because the bool is still set to false? ) In Start() we reset the rotation. Resetting does nothing more than assign the original speed to the current speed. The object will now rotate slowly again. If we don't do this in Start(), the currentRotationSpeed will default to 0. So we either have to use Start() or already assign a value to currentRotationSpeed. In Update() we get the deltaTime value and apply the rotation to the object. If the bool is true, increase the rotation. If it is false, the rotation will stay the same at 25.

avatar image nicoolsen10 metalted · Jul 05, 2019 at 09:21 PM 0
Share

I tried to change some things in the script and even if I change the originalRotationSpeed it still goes the same I tried to change it from 25f to 100f and it rotates at the same speed

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

114 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to make a script when u collide with an object it disappears 3 Answers

Rotating object using mouse movement 1 Answer

Rotating an Object on Key Press! 3 Answers

Help for shots in a script 2 Answers

Can i link an object to a moving object to save performance ? 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