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
-2
Question by D3m0nE · Apr 09, 2013 at 09:36 PM · spaceshipairplaneair

AirPlane Script?

Hello everyone

i just need very little help here,

i'm searching for simple Airplane Script

W to Increase the speed S to Dicrease the speed A,D To Rotate

Fly up and down depending on MOUSE Aim,

[C#]

i hope you can help me, and how i can make it fly

should i use the same of FPS but change the "Graphic" Part?

Comment
Add comment · Show 4
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 Benproductions1 · Apr 10, 2013 at 04:37 AM 1
Share

@D3m0nE Can you bake a Cake for me? If not, why should I write a script for you?

avatar image D3m0nE · Apr 10, 2013 at 10:39 AM 0
Share

id you dont want to,, then dont,, just show me where i can find it

avatar image Dracorat · Apr 10, 2013 at 11:22 PM 0
Share

http://lmgtfy.com/?q=unity+airplane+controller+script

avatar image Unitraxx · Apr 11, 2013 at 12:08 AM 0
Share

It's one of those questions that should not have left the queue.

2 Replies

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

Answer by RyanZimmerman87 · Apr 10, 2013 at 11:47 PM

Hmm this is borderline to in depth an answer for me to want to give right now I should be working on my own game! I guess I'll try a quick one though. I haven't made a flying game with the controls like this though so this is just what I presume would work...

This code will work for aiming assuming it is a first person perspective.

I cannot take credit for this aim script, I used this when I was first learning, not sure where it's from anymore. It may have been altered from it's original state as well so you can mess with the numbers.

 using UnityEngine;
 using System.Collections;
 
 /// MouseLook rotates the transform based on the mouse delta.
 /// Minimum and Maximum values can be used to constrain the possible rotation
 
 /// To make an FPS style character:
 /// - Create a capsule.
 /// - Add the MouseLook script to the capsule.
 ///   -> Set the mouse look to use LookX. (You want to only turn character but not tilt it)
 /// - Add FPSInputController script to the capsule
 ///   -> A CharacterMotor and a CharacterController component will be automatically added.
 
 /// - Create a camera. Make the camera a child of the capsule. Reset it's transform.
 /// - Add a MouseLook script to the camera.
 ///   -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.)
 
 [AddComponentMenu("Camera-Control/Mouse Look")]
 public class MouseLookScript : MonoBehaviour 
 {
     public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
     public RotationAxes axes = RotationAxes.MouseXAndY;
     
     public float sensitivityX = 10F;
     public float sensitivityY = 10F;
     
     public float minimumX = -360F;
     public float maximumX = 360F;
 
     public float minimumY = -60F;
     public float maximumY = 60F;
 
     float rotationY = 0F;
     
     void Start ()
     {
         // Make the rigid body not change rotation
         if (rigidbody)
             rigidbody.freezeRotation = true;
     }
     
     //lateUpdate(); ?
     void Update ()
     {
         
         if ((axes == RotationAxes.MouseXAndY) && (GlobalDataScript.cursorState==1))
         {
             float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
             
             rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
             rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
             
             transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
         }
         else if ((axes == RotationAxes.MouseX) && (GlobalDataScript.cursorState==1))
         {
             transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
         }
         else if (GlobalDataScript.cursorState==1)
         {
             rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
             rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
             
             transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
         }
     }
 }



This code for other controls:

 int flyingSpeed = 100;
 int speedChange = 20;
 
 int rotationInt = 2;
 
 Update()
 {
 
 if (Input.GetKeyDown (KeyCode.W))
         {
             flyingSpeed += speedChange;
         }
 
 if (Input.GetKeyDown (KeyCode.S))
         {
             flyingSpeed += -speedChange;
         }
 
 if (Input.GetKey (KeyCode.A))
         {
             transform.RotateAround (transform.position, transform.up, -rotateInt);
         }
 
 if (Input.GetKey (KeyCode.D))
         {
             transform.RotateAround (transform.position, transform.up, rotateInt);
         }
  }

FixedUpdate() {

transform.position += transform.forward flyingSpeed Time.deltaTime;

}

You might have to adjust some variables like the speed, the speed change, and the rotationInt to get it to fly how you want.

If you apply these scripts to the plane gameObject and set the camera to be the central transform position this work. Just make sure if you are using a rigid body you turn off the gravity.

I'm not sure how well this will work like I said I never made a flying game like this. But this should at least get you started.

Comment
Add comment · Show 4 · 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 Loius · Apr 11, 2013 at 12:04 AM 0
Share

well i'm not even gonna look at it 'cause i'm appalled by the question, but thumbs-up for effort.

avatar image Benproductions1 · Apr 11, 2013 at 03:58 AM 0
Share

Why would you answer properly to an unproper question? Good job though...

avatar image D3m0nE · Apr 11, 2013 at 08:54 AM 0
Share

thank you, Its kinda work :) i just need to add some effect xD

btw : should i change the Drag or Angular Drag or something?

avatar image Chronos-L · Apr 11, 2013 at 09:30 AM 0
Share

If you want drag and angular drag, you are going for a simulation, not just a transformation-control plane, but a real physics-controlled plane, and that needs a whole lot more codes than these.

avatar image
1

Answer by Benproductions1 · Apr 10, 2013 at 11:13 PM

@D3m0nE google.com

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

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

16 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

Related Questions

How to create air in the rooms 1 Answer

Warp drive and sound on key press 0 Answers

How do i keep an object from rotating? 2 Answers

Space Torpedo 1 Answer

Weapons Range Projectile script 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