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 davej420 · Mar 04, 2013 at 08:08 AM · controllerhelicopter

Scripting Halp!! Basic Helictopter Controller

I need to write/edit a script to control a helicopter with super basic movements.

WASD: forward, left, backward, right

Space: lift (it would be nice to have it float a bit when released)

That's it. I have no real working knowledge of creating a script from scratch but I can make adjustments once I have one in place. Anything will help, even a link to something obvious!

This is my first time ever trying to script something in Unity.

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

2 Replies

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

Answer by gfvfubb · Mar 06, 2013 at 06:00 AM

I would start with the AngryBots controller and add to it the Unity wiki script for rigidbody spaceship controls since it has a rigidbody up/down/left/right that you could add upward propulsion to. http://wiki.unity3d.com/index.php/ShipControls

http://unitycoder.com/blog/2012/12/15/photon-networking-multiplayer-game/

That describes how to strip down the scene. Once it's stripped check PlayerMoveController and FreeMovementMotor. If you add new controls to PMC and then add corresponding adjustments with rigidbody.AddForce in FMM (replaced with Ship controls) you can get upward propulsion that follows gravity and then you can modify the WASD controls to act more 'helicopter'-ish.

This also provides you with a pre-established framework to re-set animations from the player model.

To get a helicopter from those player controls, you could add a throttle set to W / S and have that AddForce ( character.up , ..etc.). If you google 'banking controls unity' you can see that you can parent a gameobject and add quick banking. You can also add rotational forces with with Torque and connect it to A / D or Q / E or whatever and get a proto-helicopter.

Comment
Add comment · Show 1 · 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 davej420 · Mar 06, 2013 at 01:09 PM 0
Share

Thanks for the comment. I have been playing around with the assets from angry bots and its really exactly what I was trying to do. Except my axises for the heli gameobject are all fucked so I had to rework the script to get it working. Also today I tried the add force applied to the rigid body and it works great!

Ill post my current script in a while. It's messy but I would like some feedback on my formatting and such.

Thanks again for the help!!

avatar image
0

Answer by black pigeon · Mar 04, 2013 at 09:32 AM

do you have animation on your model?

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 davej420 · Mar 06, 2013 at 12:51 AM 0
Share

No animations yet. I'm planning to add animations in blender for simple tilt and pitch when it moves forward and side to side. this game is not so much a heli simulator but more of a 3rd person shooter.

Here's my basic script so far. Having problems with lift function. when the copter goes up it stops after a short while and starts falling again. even when i hold down shift it just falls slower...

Any tips would be great. (the vectors were messed up in the .blend so the coordinates seem wrong but it works like it should except for lift.)

var liftSpeed : float = 50.0; var speed : float = -50.0; var rotationSpeed : float = 80.0;

function Start () {

}

function Update () {

if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.Space))

  transform.Translate (0,0, liftSpeed *Time.deltaTime);
  
  
  
 var translation : float = Input.GetAxis ("Vertical") * speed;
 var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed; 
 
 
 translation *= Time.deltaTime;
 rotation *= Time.deltaTime;
 
 
 transform.Translate (translation,0,0);
   
 transform.Rotate (0,0,rotation);
  

}

avatar image black pigeon · Mar 06, 2013 at 05:51 AM 0
Share

I've tried your script, I made a cube...

I dont know what axis that you've used as front, so I use z(+)axis as front of my heli

When I press W it strafes right, S strafes left, A tilts left, and D tilts right

When I press space it moves forward

I'm not using rigidbody to add gravity by the way,

Am I see it wrong? Or is that what you've been making?

avatar image davej420 · Mar 06, 2013 at 01:05 PM 0
Share

I don't think you're wrong. The axises are screwed up for my helicopter game object. I did not align them in blender before importing. I had to adjust the value coordinates within each function to get it to work.

The WASD actually work quite nice and I'm going to add animations to give it a pitch effect. I have added rigid body component and use gravity. As of this writing I reworked the space bar function. Ins$$anonymous$$d it now it adds force to simulate lift.

Thanks for the help btw, I think my first real lesson is to get my axises aligned before asking for help. :P

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

12 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Sailing Ship Control Script Help 1 Answer

Lock target and orbit it 3 Answers

Snowmobile script (being able to drive it) 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 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