• 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 EvilSquid · Aug 16, 2013 at 10:23 AM · c#increaseaircraft

How can I increase the amount of force over time?

Hi! I'm currently developing a flight simulator type game, and at the moment I'm working on the code for the actual physics of the aircraft, such as throttle and lift etc. I've used AddRelativeForce to create my throttle and yeah, it works, but it just jumps to that speed. So it's not very realistic, therefore what I would like to happen is that the user must hold down the throttle until it reaches the correct speed, therefore making the speed increase over time (eg. at 5 seconds it's at 50 m/s and after 20 seconds of holding it down it's at 250 m/s).

This is probably very easy, but I'm new to coding so I haven't seen it :P

The code I'm using is:

 if(Input.GetButtonDown ("Throttle"))
         rigidbody.AddRelativeForce(0,0,-500000);

Thanks :)

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
Best Answer

Answer by 2d4Games · Aug 16, 2013 at 11:29 AM

Rigidbody.AddRelativeForce should be adding force over time, and giving you that smooth acceleration that you're looking for. However, I notice you have it set incredibly high, so it may simply be that you're adding so much force that it looks like its starting instantly.

Try lowering the force value from -500000. Also, if that doesn't work, there is a variable called rigidbody.drag. It slows down the speed of the rigidbody as it moves. You could try increasing the drag of your plane by setting the drag to be higher.

One last thing to look at is the mass. AddForce and AddRelativeForce both take the mass into account when looking at adding forces. Maybe you have your mass set too low, and the force just moves it too fast.

Fiddling with those three things should fix your problem.

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 EvilSquid · Aug 16, 2013 at 12:20 PM 0
Share

Ah, right, I see! Thank you! It's currently on FixedUpdate, so should it be on Update or is FixedUpdate the right one?

avatar image 2d4Games · Aug 16, 2013 at 12:47 PM 0
Share

Transformations should normally be done during FixedUpdate, so you have that right.

avatar image EvilSquid · Aug 16, 2013 at 01:22 PM 0
Share

Okay, sorry, one final issue. I have adjusted the drag and mass (because my mass was just at a stupid value) and now it starts at a good rate and I get it in the air then it just slows back down.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How Return Or Restart A Coroutine When A Variable Increase? 0 Answers

Renderer on object disabled after level reload 1 Answer

How Return Or Restart A Coroutine When A Variable Increase? 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