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 Durante · Nov 10, 2011 at 02:13 AM · javaairplane

help me please i dont get it

i created a script for a jet for my game The HOUR and this is wat i got and when i turn on the game...all the keys are backwards and the plane stays facing strait. here is my script

static var gameover = 0; var crashforce = 0; static var rotationx = 0; static var airplaneangley : float = 0.0; static var rotationy : float = 0.0; static var rotationz : float = 0.0; var positionx : float = 0.0; static var positiony : float = 0.0; var positionz : float = 0.0;

static var speed : float = 0.0; var uplift : float = 0.0; var pseudogravitation : float = -0.3;

var rightleftsoft : float = 0.0; var rightleftsoftabs : float = 0.0;

var divesalto:float =0.0; var diveblocker:float=0.0;

function Update () { airplaneangley= transform.eulerAngles.y;

 if ((gameover==2) && (Input.GetKey ("enter"))||(gameover==2) &&(Input.GetKey ("return")))    {
     gameover=0;
     rigidbody.useGravity = false;
     transform.position = Vector3(0, 1.67, 0);
     transform.eulerAngles = Vector3(0,0,0);
 }

 if (gameover==1)    {
 rigidbody.AddRelativeForce (0, 0, crashforce);
 gameover=2;
 }

 if (Input.GetKey("f2")){

     speed=0;
     gameover=0;
     rigidbody.useGravity = false;
     Application.LoadLevel(0);
     } 

 if(gameover==0){

     rotationx=transform.eulerAngles.x; 
     rotationy=transform.eulerAngles.y; 
     rotationz=transform.eulerAngles.z; 
     positionx=transform.position.x;
     positiony=transform.position.y;
     positionz=transform.position.z;

     if ((Input.GetAxis("Vertical")<=0)&&((speed>595))) {
         transform.Rotate((Input.GetAxis("Vertical")*Time.deltaTime*80),0,0); 
     }

     if ((Input.GetAxis("Vertical")>0)&&((speed>595))){
         transform.Rotate((0.8-divesalto)*(Input.GetAxis("Vertical")*Time.deltaTime*80),0,0); 
     }

     if (groundtrigger.triggered==1) transform.Rotate(0,Input.GetAxis("Horizontal")*Time.deltaTime*30,0,Space.World); 

     if (groundtrigger.triggered==0) transform.Rotate(0,Time.deltaTime*100*rightleftsoft,0,Space.World); 


     if ((Input.GetAxis ("Horizontal")<=0)&&(rotationz >0)&&(rotationz <90)) rightleftsoft=rotationz*2.2/100*-1;
     if ((Input.GetAxis ("Horizontal")>=0)&&(rotationz >270)) rightleftsoft=(7.92-rotationz*2.2/100);

     if (rightleftsoft>1) rightleftsoft =1;
     if (rightleftsoft<-1) rightleftsoft =-1;

     if ((rightleftsoft>-0.01) && (rightleftsoft<0.01)) rightleftsoft=0;

     rightleftsoftabs=Mathf.Abs(rightleftsoft);

     if (rotationx < 90) divesalto=rotationx/100.0;
     if (rotationx > 90) divesalto=-0.2;

     if (rotationx <90) diveblocker=rotationx/200.0;
     else diveblocker=0;

     if ((rotationz <180)&&(Input.GetAxis ("Horizontal")>0)) transform.Rotate(0,0,rightleftsoft*Time.deltaTime*80);
     if ((rotationz >180)&&(Input.GetAxis ("Horizontal")<0)) transform.Rotate(0,0,rightleftsoft*Time.deltaTime*80);

     if (!Input.GetButton ("Horizontal")){
         if ((rotationz < 135)) transform.Rotate(0,0,rightleftsoftabs*Time.deltaTime*-100);
         if ((rotationz > 225)) transform.Rotate(0,0,rightleftsoftabs*Time.deltaTime*100);
         }
         
     if ((!Input.GetButton ("Vertical"))&&(groundtrigger.triggered==0)){
         if ((rotationx >0)&&(rotationx < 180)) transform.Rotate(Time.deltaTime*-50,0,0);
         if ((rotationx >0)&&(rotationx > 180)) transform.Rotate(Time.deltaTime*50,0,0);
         }

     transform.Translate(0,0,speed/20*Time.deltaTime);

     if ((groundtrigger.triggered==1)&&(Input.GetButton("Fire1"))&&(speed<800)) speed+=Time.deltaTime*240;
     if ((groundtrigger.triggered==1)&&(Input.GetButton("Fire2"))&&(speed>0)) speed-=Time.deltaTime*240;
     
     if ((groundtrigger.triggered==0)&&(Input.GetButton("Fire1"))&&(speed<800)) speed+=Time.deltaTime*240;
     if ((groundtrigger.triggered==0)&&(Input.GetButton("Fire2"))&&(speed>600)) speed-=Time.deltaTime*240;
 
     if (speed<0) speed=0; 
     
 if ((groundtrigger.triggered==0)&&(!Input.GetButton("Fire1"))&&(!Input.GetButton("Fire2"))&&(speed>695)&&(speed<705)) speed=700;

     if((Input.GetButton("Fire1")==false)&&(Input.GetButton("Fire2")==false)&&(speed>595)&&(speed<700)) speed+=Time.deltaTime*240.0;
     if((Input.GetButton("Fire1")==false)&&(Input.GetButton("Fire2")==false)&&(speed>595)&&(speed>700)) speed-=Time.deltaTime*240.0;

     transform.Translate(0,uplift*Time.deltaTime/10.0,0);

     uplift = -700+speed;

 if ((groundtrigger.triggered==1)&&(uplift < 0)) uplift=0; 
 
 if (speed <595){

 if ((sensorfront.sensorfront ==0)&&(sensorrear.sensorrear ==1)) transform.Rotate(Time.deltaTime*20,0,0);

 if ((sensorfront.sensorfront ==1)&&(sensorrear.sensorrear ==0)) transform.Rotate(Time.deltaTime*-20,0,0);

 if (sensorfrontup.sensorfrontup ==1) transform.Rotate(Time.deltaTime*-20,0,0);

 if (groundtrigger.triggered==0) transform.Translate(0,pseudogravitation*Time.deltaTime/10.0,0);

 }
 
 if (Input.GetKey ("1")) {
 transform.position.y=200;
 speed=700;
     }
     
 }

 if (transform.position.x >= 900.0) transform.position.x = 0;
 else if (transform.position.x <= -900.0) transform.position.x = 900.0;
 else if (transform.position.z >= 900.0) transform.position.z = 0;
 else if (transform.position.z <= -900.0) transform.position.z = 900.0;
 
 if (positiony > 1000) transform.position.y = 1000;

}

function OnCollisionEnter(collision : Collision) { if (groundtrigger.triggered==0) { groundtrigger.triggered=1; crashforce= speed*10000; speed=0; gameover=1; rigidbody.useGravity = false; } }

Comment
Add comment · Show 2
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 DayyanSisson · Nov 10, 2011 at 03:45 AM 1
Share

What do you want this script to do exactly? Is it supposed to control the game's systems? Do you want it to control the plane's movement. How do you want the plane to move? Using WASD or the arrow keys. Be specific, as I'm not sure how to answer, or what you're trying to achieve. (Next time, make sure you format code right).

avatar image Durante · Nov 10, 2011 at 04:09 AM 0
Share

i want it to control the airplanes movement...up be down and down be up and regular left go left and right go right.

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Airplane Script Control 1 Answer

Select frame for Animation 1 Answer

Stand alone player 0 Answers

Gun recoil and gun reload 2 Answers

Aircraft controller script 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