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 Zitoox · Sep 20, 2016 at 11:02 PM · movementscripting beginnerrotate objectcontrolshelicopter

Helicopter Controls

Hi! I am trying to make a Helicopter, but the results so far were pretty... disappointing...

I wish to make a Helicopter. But not just a wish, it's a DREAM. I am actually starting to go insane because of this xD

I wanted to make a FULL WORKING HELICOPTER, so i started it. I made glass for the windows, i adjusted both the rotors (main and rear), i adjusted the camera, the setup, but now i am stuck on what i believe to be the hardest part of it. I wanted to make the Controls, but i am having some serious problems. I have a script that make the helicopter fly when i press the space bar, but i am having trouble with the directional controls.

I want to make the helicopter smoothly start to rotate when the player press A or D. Rotate 90 degrees. I also want to make the helicopter go forward when the player press W and backward when the player press S.

I've tried everything, but i can't do this =( I am just a beginner at scripting yet, so i don't know much about this. I tried some tutorials, asked some questions, but i still don't know what to do! How can i make this? I seriously don't know. Could someone help me? This is making me crazy =\

So far, i could only make some strange combination of things that resulted in my helicopter crashing in the ground, going insane while in the air or literally starting to move like it was rebelling itself, but it's because my scripts are ridiculously bad made... alt text

This is my helicopter. I don't know if anyone can help me, but i still would like to thank you guys, because i didn't knew even the basic things when i started and you all helped me, and i am slowly becoming a good developer =)

dream.png (379.0 kB)
Comment
Add comment · Show 1
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 Drakonno · Sep 21, 2016 at 12:42 AM 0
Share

Feel free to send me private message on unity-forum. It's quite broad and complex idea, depending mostly on how perfect beahaviour You want, and doesn't fit well into QA format. Still better than many other questions I've seen.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ForeignGod · Sep 21, 2016 at 09:20 AM

This is not tested but should give you some ideas.

 //Adjust these!
 var speed = 30;
 var fspeed = 30;
 var bspeed = 30;
 var lift = 30;
 //
 
 var helirb: Rigidbody;
 
 function Start() {
     helirb = GetComponent.<Rigidbody>();
 }
 function Update () {
  
   if (Input.GetKey(KeyCode.A)){
       transform.Rotate(Vector3.left * speed * Time.deltaTime);
       }
   if (Input.GetKey(KeyCode.D)){
       transform.Rotate(-Vector3.right * speed * Time.deltaTime);
       }
  }
 
 function FixedUpdate () {
 
   if (Input.GetKey(KeyCode.W)){
         helirb.Addforce(transform.forward * fspeed * Time.deltaTime);
         //Add tilt rotation maybe for visual purposes?
         }
         
   if (Input.GetKey(KeyCode.S)){
         helirb.AddForce(-transform.forward * fspeed * Time.deltaTime);
         //Add tilt rotation maybe for visual purposes?
         }
   if (Input.GetKey(KeyCode.Space)){
         helirb.AddForce(transform.up * lift * Time.deltaTime);
         }
 }

EDIT: Fixed some small errors.

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 Zitoox · Sep 21, 2016 at 04:28 PM 0
Share

There are some errors on it: alt text

I could only repair some things, but there are some errors that i believe can't be fixed without changing the entire script.

errors.png (21.7 kB)
avatar image ForeignGod Zitoox · Sep 22, 2016 at 06:25 AM 0
Share

Try out the newest revision. Just remember to edit your ridigbody's settings accordingly. $$anonymous$$ight seem like it doesn't work at first :)

avatar image Zitoox ForeignGod · Sep 22, 2016 at 06:52 PM 0
Share

I am still getting "back is not a member of unity engine transform" =\

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

65 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 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 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 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 avatar image

Related Questions

Merging pathfinding and following the player Scripts 0 Answers

How do i move around in the editor without using arrow keys or middle click. 1 Answer

Force Movement on a Path with Path Switching? 0 Answers

Character Movement won't work properly because of the rotation 1 Answer

Movement speed of 2 players not matching 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