• 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

How to make a recursion with created objects 2 Answers

move UI object to click position 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges