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 /
This question was closed Dec 14, 2015 at 08:09 PM by Lepanto7 for the following reason:

Answered my own question

avatar image
0
Question by Lepanto7 · Dec 14, 2015 at 10:11 AM · velocityscripting beginnerflying

How to move an airplane in the Z axis?

I'm using a modified plane-flying script from the Asset Store on the player's plane. Now, it's a fine script, BUT it's hard to change the script without breaking something.

Specifically, I'm trying to give the player the ability to slide on the X and Y axis, in addition to your normal thrust on the Z-axis. But the script moves the player along the Z-axis by setting the rigidbody's velocity, and I'm trying to move the player along the X and Y axes by using AddRelativeForce. "velocity =" and AddRelative Force don't play well with each other.

How do I make the plane move properly on all three axes?

Here's the relevant code: relevant variables:

 public float speed = 20.0f; //"Base Speed", "Primary flight speed, without afterburners or brakes"
     public float speedX = 20.0f; //"Horizontal Slide Speed", "Slide speed along the X-axis"
     public float speedY = 20.0f; //"Vertical Slide Speed", "Slide speed along the Y-axis"
     public float afterburner_speed = 40f; //Afterburner Speed", "Speed when the button for positive thrust is being held down"
     public float slow_speed = 4f; //"Brake Speed", "Speed when the button for negative thrust is being held down"
 
 
 float currentMag = 0f; //Current speed/magnitude (this is the player ship's thrust magnitude, set earlier in the script)
     
 -----------------------------------------------------------------
 
 thrust coding
 
         //Apply all these values to the rigidbody on the container.
         GetComponent<Rigidbody>().AddRelativeTorque(
             (pitch * turnspeed * Time.deltaTime),
             (yaw * turnspeed * Time.deltaTime),
             (roll * turnspeed *  (rollSpeedModifier / 2) * Time.deltaTime));
 
 
 
         GetComponent<Rigidbody>().velocity = transform.forward * currentMag; //Apply speed
 
 
         GetComponent<Rigidbody>().AddRelativeForce(
             (Input.GetAxis("Horizontal") * speedX * 2),
             (Input.GetAxis("Vertical") * speedY),
             0
             )            ;

I just get the feeling that I'm missing something here, that there's some way to fix the problem by using AddRelativeForce on all axes. I KNOW there is; I achieved all-axes flying once before, before stupidly deleting my old work and having to start from scratch.

So, can anyone help a newb make planes fly?

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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Object flickers back and forth if it reaches mouseposition. 0 Answers

How to set velocity to new direction after rotation? 0 Answers

Velocity powered rigidbody on a moving platform without parenting. 3 Answers

Help with sliders 1 Answer

How to Pick up 1 collider Object at a time, Vs. all at once? 2 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