Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 jonmar2348 · Aug 16, 2011 at 10:14 PM · controlsflyingairplanelift

Airplane Controls - Lift

Hi, I'm trying to make my plane lift off and ascend, but instead it descends. Can anyone help me? Thank you.

var liftSpeed = 20.0;

function FixedUpdate(){

 if(Input.GetButton("Lift")) 

 {

     transform.position += transform.forward * liftSpeed * Time.deltaTime;

 }

}

Comment
Add comment · Show 3
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 flaminghairball · Aug 16, 2011 at 10:19 PM 1
Share

That code will only make your plane move along its local forward axis.

avatar image logty · Aug 16, 2011 at 11:17 PM 0
Share

Change your transform.forward to transform.position.y, see if that works

avatar image aldonaletto · Aug 16, 2011 at 11:38 PM 0
Share

@Fla$$anonymous$$gHairball is right: this code only moves forward - and if your plane has a rigidbody and use gravity, it will descend.

1 Reply

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

Answer by aldonaletto · Aug 16, 2011 at 11:35 PM

If you just want it to ascend vertically, use:

  transform.Translate(Vector3.up * liftSpeed * Time.deltaTime);
It will go up like a Sea Harrier.
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 Mickman · Jun 10, 2012 at 04:04 PM 0
Share

I've started to play around with aircraft dynamics.. I am new to all this .. I have my craft hovering and controls are more like a helicopter.

here's a sample of code

function FlyForward (){
if (Input.GetButton("Forward")){ energy = Time.deltaTime * 50; rigidbody.AddRelativeForce (10,0,0);
rigidbody.AddRelativeTorque (0,0,-4); // tilt forwards print (" Forward Thrust Active "); }

I am trying to achieve stable turns. Currently my craft tends to yaw rather than bank. Is it ok to use rigidbody.AddRelativeForce as apposed to rigidbody.AddForce ??

avatar image aldonaletto · Jun 10, 2012 at 09:29 PM 0
Share

AddForce is based on world coordinates. For a spaceship or airplane, it makes more sense to use AddRelativeForce, because the ship will move in its local direction - a jet will push the airplane to its forward direction, for instance. For an airplane, the gravity is the only world related force; for a spaceship, usually there are no world based forces.
But if you apply a relative force and a relative torque, the airplane may behave like an untied party balloon when we release its neck - the force will push it forward, but the torque will make the forward direction change.
A better alternative is to make the airplane model a child of the actual rigidbody: create an empty game object, add a suitable collider (box or capsule) and a rigidbody - this will be your actual airplane. Child the airplane model to it, and when necessary fake the banking by modifying the model's transform.localEulerAngles. Applying torque to a rigidbody usually isn't a good idea: the rigidbody spins ins$$anonymous$$d of just turn to the desired direction. To turn left or right, for instance, it's better to rotate the transform with transform.Rotate - the rigidbody follows the transform, thus it will go in the new direction.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Developing a 2D flying game similar to Retry by Rovio. 0 Answers

Helicopter controls inverted 1 Answer

control script for airplane 4 Answers

Applied force is increasing over time? 1 Answer

Accelerometer Plane Controls help 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