Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Estevominador · Apr 16, 2012 at 06:44 PM · rotationspinhelicopter

Rotation stops when reach the limit.

I have a script of an helicopter and, when Main rotors reach the max speed, they stop to spin. how to solve that?

it's like this:

 var rotation = 0;
 var speed = 0;
 var maxspeed = 20000;
 
 function Update (){
     rotation += 0.001 * Time.deltaTime;
     speed += rotation * 15;
     
     if(speed > maxspeed){
         speed = maxspeed;
     }
 }

thx any advance.

Comment
Add comment · Show 1
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 rutter · Apr 16, 2012 at 07:07 PM 0
Share

What code is actually making the rotors spin?

Is this the only code which adjusts these values?

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Apr 16, 2012 at 09:12 PM

I'm also interested in where you actually rotate the object?

Anyway, i guess your problem is that you use int variables! All say Unityscript (Javascript) is easier, but that's one of the pitfalls ;)

You didn't specify a variable type so the type is determined via type-inference. Since you initialize your variables with integer values (0 and 20000) they become int variables. You need float variable so you can store fractional numbers. You can either give your variables a type manually:

 var rotation : float = 0;
 var speed : float = 0;
 var maxspeed : float = 20000;

or initialize the variables with floats:

 var rotation = 0.0;
 var speed = 0.0;
 var maxspeed = 20000.0;


Comment
Add comment · 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
-1

Answer by hesa2020 · Apr 16, 2012 at 08:38 PM

This is a script you can use, i dont know if it work i dont tested it yet Just name this script : HelicopterRotation.cs Here the script : CLICK TO GET THE SCRIPT

Comment
Add comment · Show 1 · 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 Bunny83 · Apr 16, 2012 at 09:00 PM 0
Share

This is a horrible script ;) :

  • The spin down doesn't work since you rotate only when "On == true".

  • The RotationSpeed increase is frame dependent.

  • No way to change the spin-up time / speed

  • Using int for speed is very strange.

  • Using the inequality operator to limit an increase or decrease is very bad style. It works only with int values and only when you increase / decrease by 1.

  • Start should be removed when it's not used. This will increase the performance (well almost nothing, but it's a fact)

avatar image
0

Answer by CaptainIcy281 · Apr 16, 2012 at 08:14 PM

It looks like all you need is something like this.

 if(speed >= maxspeed) //>= is greater than or equal to
 {
   speed = 0;
 }

And handle the rotation as you normally would. All you need is to tell it to "stop" when it reaches the max speed.

Or do you need something more than this? I didn't exactly understand your question perfectly.

Comment
Add comment · 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
0

Answer by Estevominador · Apr 20, 2012 at 01:15 PM

thank you guys! I'll really think about it! thx

Comment
Add comment · 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

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Simple rotation script. (loop) 3 Answers

Constant rotation? 2 Answers

Spinning a mesh independent of its forward movement? 1 Answer

How Rotate Object To Resemble Spinning? 1 Answer

How do I instantly change the direction of rotation of a gameobject? 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