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 shaibam · Jul 01, 2015 at 03:59 PM · 2dgravity2d-physicshelicopterpower

2d Helicopter simulation (gravity vs. force question)

Looking for suggestions for gravity and Y axis forces for helicopter game... I am creating a helicopter game and it and looks to me that the default gravity force for the 2drigidbody is too strong. in my code when pressing the down keyboard key I apply force to the gameobject 2dVector.y, and when releasing the key I gradually decrease the applied force until it reaches 0. my problem is that it seems that the default gravity value is pulling the object too strong.

any suggestion for the best values to apply to the gameobject ?(gravity,Force Increase by value , Force decrease by value) or maybe even a change in the Project - "Physics2DSettings"?

and if I want to apply constant force against the gravity factor, how can I calculate the force that should be applied to keep the chopper from falling down or rocketing to the sky?

using UnityEngine; using System.Collections;

public class testSCript : MonoBehaviour { public Rigidbody2D r_2d ; public float POWER_FACTOR = 0.5f; public Vector2 power_vector = new Vector2(0,10); public float power_dec = 0.99f; public float MAX_POWER = 10.9f; public float MAX_VELOCITY = 3f; public float current_velocity; // Use this for initialization void Start () { r_2d = this.GetComponent(); }

 // Update is called once per frame
 void Update () {
     if (Input.GetKey ("down")) {
         power_vector.y += POWER_FACTOR;
         if (power_vector.y>MAX_POWER) {
             power_vector.y = MAX_POWER;
         }
     } //else {
     if (power_vector.y > 0.01)
         power_vector.y *= power_dec;
     else 
         power_vector.y = 0;
     //}
     current_velocity = r_2d.velocity.y;

     if (current_velocity<MAX_VELOCITY) {
         r_2d.AddRelativeForce(power_vector);
     }
 }

}

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

Answer by Bunny83 · Jul 02, 2015 at 11:23 AM

You should increase your drag value to simulate air resistance. Without drag objects will fall like they would in vacuum. Unity uses a simple linear drag force. This has nothing to do with real world air resistance (which is quadratic in relation to the velocity). Though in most cases the linear model is just fine to simulate air resistance.

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 NoseKills · Jul 02, 2015 at 11:10 AM

looks to me that the default gravity force for the 2drigidbody is too strong

The default gravity is set so that all objects should get the acceleration of 9.81 m/s^2 just like they in real life (so 1 world unit == 1 meter by default). If your chopper object is smaller than a real chopper would be, then it will appear to fall too fast in relation to your scene's scale with this gravity setting (like a small toy chopper).

Also

when releasing the key I gradually decrease the applied force until it reaches 0

Remember that forces cause acceleration, so decreasing the force gradually will not slow down the chopper's downward movement, it will just slow down the downward acceleration; its downward speed will still increase every frame (even if you turned off gravity altogether).

Did you take a look at the ForceModes ? You can add them as the second parameter of your AddRelativeForce call. Especially if your chopper consists of only 1 rigidbody, it should be fairly easy to control it using ForceMode.Acceleration or ForceMode.VelocityChange

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to walk on a circular object unity 2d 2 Answers

Horizontal attraction? 0 Answers

How to track transform.position in real time? 1 Answer

Can I access Physics2dSettings in Project Settings via script 1 Answer

Instantiated prefab changes gravitational speed when dragged? 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