Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 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 hema · Mar 13, 2014 at 09:27 AM · rotationspeedcircular

Dividing the circular rotation into parts?

Hi all,

I have a requirement that a Game Object should rotate in clockwise circular motion and divide the whole circular path into 6 parts and Randomize the movement speed in each part. Please suggest me ideas to do this.

Thanks, Hema

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by hema · Mar 14, 2014 at 09:51 AM

Have found a way using Quaternion.Euler. Below is the code: m_Rotation += 1.0f; transform.rotation = Quaternion.Euler(new Vector3(0,0,-m_Rotation * m_Speed)); if(m_Rotation == 360) { m_Rotation = 0; } if(m_Rotation < 60) { m_Speed = 1; } if(m_Rotation > 60 && m_Rotation < 120 ) { m_Speed = 2; } But dint get a smooth transition. Help me to improve the answer.

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 StrykerS. · Mar 14, 2014 at 10:27 AM 0
Share

What you want is the Lerp function. To use it in your code change.

 transform.rotation = Quaternion.Euler(new Vector3(0,0,-m_Rotation * m_Speed));

to

 transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(new Vector3(0,0,-m_Rotation * m_Speed)), Time.deltaTime * 5);

You can adjust the smooth rate by changing Time.deltaTime 5 to Time.deltaTime whatever you want. Higher numbers will of course make it move faster.

avatar image StrykerS. · Mar 14, 2014 at 10:31 AM 0
Share

Also the first post I made has many typos's as I was hastily typing it out just in the unity answers text box and did not test it in unity or monodevelop but the logic used in it is sound. I am going to delete it though as it is not very helpful in it's current state.

avatar image hema · Mar 14, 2014 at 10:36 AM 0
Share

Ya that works fine. Thanks you so much.

avatar image
0

Answer by jaapflonk · Mar 13, 2014 at 10:06 AM

I dont understand your question, but this might work:

using UnityEngine; using System.Collections;

public class example : MonoBehaviour {

 public float randomNumber;
 public float timer = 0f;
 
 void Start() {
     randomNumber = Random.Range(1, 10);
 }
 
 void Update() {
     timer += Time.deltaTime * 1;
     print(timer);
     if (timer > randomNumber) {
         Rotate();
         randomNumber = Random.Range(1, 10);
         timer = 0;
     }
 }
 
 void Rotate() {
      transform.Rotate(Vector3.left * 60);
 }

}

Every 0 to 10 seconds it will rotate 60 degrees

Comment
Add comment · Show 2 · 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 hema · Mar 13, 2014 at 11:38 AM 0
Share

The Game object will be moving in a circular motion. One full rotation should be divided into 6 parts. Each part should have different speed.

avatar image hema · Mar 13, 2014 at 11:44 AM 0
Share

Usually one rotation takes 90 degrees it seems from the document so need different speed in each 15 degrees rotation.

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

22 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

Related Questions

Different speed on different phones 0 Answers

Instant Rotation 2 Answers

Decreasing object rotation speed until it stops? 0 Answers

Turret: Getting a constant rotation speed 2 Answers

Rotate an object in a specific time 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