• 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 sam32x · Nov 26, 2011 at 07:36 AM · movingtransform.translatesomethingstupid

gravity gets too strong and plane falls to the ground help

i have an aeroplane and when i fly it it works normally but after a while the gravity gets really strong and it just crashes, i am using transform.translate to move, so the rigidbody is probably falling down and the transform.translate doesnt stop it. can someone change this script to one that will work?

 var movespeed = 0;
 var turn = 0;
 var noseup = 0;
 var F22Model : GameObject;
 var explosion : GameObject;
 var crashed = 1;
 var maxspeed = 600;
 var abletomove = 1;
 var eject = 0;
 var stopeject = 0;
 
 function Update () {
 
 var lift = movespeed * 0.5;
 
 transform.Translate(Vector3.right * Time.deltaTime * movespeed);
 transform.Rotate(Vector3.left * Time.deltaTime * turn);
 transform.Translate(Vector3.up * Time.deltaTime * lift);
 transform.Rotate(Vector3.forward * Time.deltaTime * noseup);
 transform.Translate(Vector3.up * Time.deltaTime * eject);
 
   if (Input.GetKey("up"))
   if (abletomove == 1)
   movespeed += 1;
   
   if (Input.GetKey("down"))
   if (abletomove == 1)
   movespeed -= 0.01;
   
   if (Input.GetKey("a"))
   if (abletomove == 1)
   turn -= 15;
   
   if (Input.GetKey("d"))
   if (abletomove == 1)
   turn += 15;
   
   if (turn <= 0)
   turn += 5;
   
   if (turn >= 0)
   turn -= 5;
   
   if (noseup <= 0)
   noseup += 5;
   
    if (noseup >= 0)
   noseup -= 5;
   
   if (Input.GetKey("s"))
   if (abletomove == 1)
   noseup += 10;
   
   if (Input.GetKey("w"))
   if (abletomove == 1)
   noseup -= 10;
   
   if (movespeed >= maxspeed){
   movespeed = maxspeed;
   }
   if(stopeject >= 300){
   eject = 0;
   }
   
   if (crashed == 0)
   if (stopeject <= 300){
   eject += 20;
   }
   }
 
 function OnCollisionEnter(thing : Collision) {
     if (thing.collider.tag == "Terrain") {
     if (crashed == 1) {
     Destroy (F22Model);
     Instantiate (explosion, transform.position, transform.rotation);
     crashed = 0;
     movespeed = 0;
     stopeject += eject;
     turn = 0;
     noseup = 0;
     maxspeed = 0;
     abletomove = 0;
     transform.Rotate(Vector3.forward * -90);
     }
     }
     }


thanks

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 syclamoth · Nov 26, 2011 at 08:10 AM 0
Share

Either get rid of the rigidbody component, or rewrite your script entirely. I'm afraid I can't really help you here- you can't have inbuilt collisions at the same time as managing all your movement from transform.Translate calls. Either manage collisions yourself as well, or rethink your script to one which works with the rigidbody system ins$$anonymous$$d of against it.

I won't write your script for you, since this is basically completely rewriting it.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

how to make an object "the target" when you click on it 3 Answers

function error 1 Answer

manabar doesnt work 1 Answer

enemy is destroyed at the start instead of when health is 0 1 Answer

Low Poly Water 4 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