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 $$anonymous$$ · Sep 04, 2014 at 04:06 AM · gravityforcehoverhelicopterlift

How to make a rigidbody hover giving it an upward force? Mine still doesn't stay even when the upward force and graviational pull are equal.

I am trying to simulate a helicopter. Just now started with it. As a trial I took a cube, applied rigidbody to it setting its mass as 2. I then applied a constant force of 19.6 (since 2 * 9.8 = 19.) upwards. What I anticipated was that it would not move since upward and downward forces are exactly equal, but it actually moves downwards(though very slowly). Increasing the force by any amount moves it upwards. Am I wrong with the physics part or there is any else. Someone please help.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by prof · Sep 07, 2014 at 09:39 AM

Something like this

     void FixedUpdate(){
         float yVel = rigid.velocity.y + Physics.gravity.y;
 
         //Howering
         rigid.AddForce(0, -yVel, 0, ForceMode.Acceleration);
 
         //Altitude
         rigid.AddForce(0, Input.GetAxis("Vertical") * 5, 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 TheBombix95 · Dec 08, 2014 at 12:58 AM

hi Iqu, I've done this so many times that I've lost the count of it. Jokes apart, here's what I've done for mine:

 function FixedUpdate () { //you have to apply the force Always in FixedUpdate function, otherwise in the Update 
 // function the force is not applied costantly, resulting in a slow fall towards the ground
 
 
     //Here we apply a force to the rigidbody's local up vector and we multiply it by the rigidbody mass
     //and the Absolute gravity up force.
     //for now it should give you a go as long as your rigidbody doesn't tilt  :S
     
     rigidbody.AddRelativeForce( Vector3.up * (rigidbody.mass * Mathf.Abs(Physics.gravity.y) ) );
     
     //How simple is that ?
 }

if you need more info on helicopter's Physics just ask me, I'm developing a physics based helicopter game

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 TheBombix95 · Dec 08, 2014 at 12:07 AM 1
Share

Sorry, I've looked in the question date and it says that the year is the 2014

avatar image MrSoad · Dec 08, 2014 at 12:59 AM 0
Share

$$anonymous$$y mistake :S Been at it for too long today, many apologies(+1) :)

avatar image TheBombix95 · Dec 09, 2014 at 09:09 AM 0
Share

don't worry ;), i hope my answer will help someone that is looking for it. I've figured it out by thinking how an helicopter hovers. They compensate their mass and the gravity by countering those two forces and...tàdà. Here's the script. I'm currently developing a combat fly simulator based on real life formulas. If anyone needs help just ask me. Bye ;)

avatar image
0

Answer by GameVortex · Sep 04, 2014 at 07:16 AM

Force and Gravitational acceleration is two different things. Force is applied with consideration of the object's mass while Gravity ignores mass. Try using Acceleration as the Forcemode: http://docs.unity3d.com/ScriptReference/ForceMode.html and you should get it to hover still. Although forcemode acceleration is probably not what you want to control your helicopter.

Normally a helicopter probably has to recalculate how much force it needs to apply to hover still. If it detects it moves upwards it has to decrease force and when it detects it moves down it has to increase force.

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 $$anonymous$$ · Sep 04, 2014 at 10:33 AM 0
Share

actually I used the physics component "constant force". Addforce doesnt seem to work here . Because "rigidbody.AddForce(new Vector3(0,9.8f,0),Force$$anonymous$$ode.Acceleration);" has to be put in update or fixedUpdate and it is not a constant force. It keeps giving a force of 9.8 upwards every frame and as a result it goes upwards.

avatar image prof · Sep 04, 2014 at 11:07 AM 0
Share

This will give you force per second. rigidbody.AddForce(new Vector3(0,9.8f,0),Force$$anonymous$$ode.Acceleration) * Time.deltaTime;

avatar image $$anonymous$$ · Sep 04, 2014 at 03:43 PM 0
Share

No it doesn't work. we can't multiply time.deltatime to a statement like that. I tried " rigidbody.AddForce(new Vector3(0,9.8f,0)* Time.deltaTime,Force$$anonymous$$ode.Acceleration) " ins$$anonymous$$d, but even this does not work.

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

Applied force is increasing over time? 1 Answer

How to make an object hover(Against gravity) 1 Answer

hinge joint help? 0 Answers

Net Force between two objects... 1 Answer

Tornado throwing back force after pulling 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