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 Grantley · Nov 27, 2011 at 03:16 PM · planeflying

How to make a 3d model plane fly?

Im new to unity3d and have been trying to make a 3d model of a fighter jet fly but dont know where to start. I've looked at other questions and tried using scripts but no script I have tried does anything so I can guess im doing something wrong so could someone please tell me how to get a script to work properly and then make a plane fly.

Much appreciated

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

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by rabbitfang · Nov 27, 2011 at 06:01 PM

Don't try to mimic physics by changing the transform's position. It can look unrealistic.

You are going to want to attach a Rigidbody component to the plane object. This will apply physics simulations to the plane. You want to create a script that applies a force to lift the plane, and a force to turn the plane.

http://unity3d.com/support/documentation/ScriptReference/Rigidbody.html

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

Answer by ptdnet · Nov 27, 2011 at 05:29 PM

You want to change the object's transform variable:

myPlane.transform.position = new Vector3(newXPosition, newYPosition, newZPosition);

Comment
Add comment · Show 2 · 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 rabbitfang · Nov 27, 2011 at 06:02 PM 0
Share

Simulating physics by changing the transform is not a very good idea. There would be a lot of calculations involved that would slow down the game as opposed to using the Physics engine.

avatar image Unity_scat · Apr 14, 2016 at 06:49 AM 0
Share

@ptdnet Once you attach the 3D rigidbody, what code in the script would make it move forward? I'm trying to make an airplane. I grouped all the objects into an empty object, and rotated it in the air so it looks like it's flying forward. I use this script, but my player doesn't move with it and can somehow go through objects.

 using UnityEngine;
 using System.Collections;
 
 public class $$anonymous$$oveForward : $$anonymous$$onoBehaviour {
 
     public float speed = 0.5f;
     public Vector3 direction = Vector3.right;
     public void Update()
     {
         transform.Translate (direction * speed * Time.deltaTime); 
     }
 }

To make my plane go forward, the directions it moves is around X 6 and Z 1. Help please!

avatar image
0

Answer by N1warhead · Apr 14, 2016 at 11:04 AM

What I would do, and this is just me.

I would apply a Rigidbody to my object. Then the technical parts (nothing fancy) but it should get you on the right track. KEEP IN MIND THIS ISN'T TESTED!!!!! (I just made this from the top of my head really quick for you).

HOWEVER, IT SHOULD IN THEORY WORK.

All this will do is, let you fly a plane from run way, reach a certain speed and start to lift. And very very basic rotations to let you rotate.

It's in NO WAY PERFECT. But should at least get you in the right direction to learning how to do this.

If this at least gets you going in the right direction please mark this as correct so others will know. Thanks buddy.

Any issues, please feel free to respond and I'll try my best to help fix them. (Not going to design the entire thing for you) - just helping you in the right basics of directions at least. //Keep in mind, this is very basic barebones to help get you going. I'll include basic rotation as well (NOT PERFECT).

 //C# SCRIPT
 public float maxSpeed;            // Our maximum speed allowed.
 public float decAltSpeed;        //Decrease Altitude.
 public float incAltSpeed;        // Increase Altitude.
 public float curSpeed;            // Current Speed;
 public float applySpeed;        // How much force to apply (Forward).
 
 public float airBrakeForce;        // Breaks.
 
 private Rigidbody myRigid;        // Our Rigidbody.
 
 void Start(){
     myRigid = GetComponent<Rigidbody>();        // Gets the players Rigidbody.
 }
 
 void FixedUpdate(){
 
 curSpeed = myRigid.velocity.z;
 
 if(curSpeed >= maxSpeed){
     //If our speed maxes out to our maxSpeed we restrict our plane from going any faster.
     applySpeed = curSpeed;
 }
 
 
     if(Input.GetKey(KeyCode.W)){
         //Apply Accelleration
         myRigid.AddRelativeForce(Vector3.forward * applySpeed);
         if(curSpeed >=incAltSpeed){
             myRigid.AddRelativeForce(Vector3.up * AnyNumberYouWant);
         }
         
     }
     if(Input.GetKey(KeyCode.S)){
         //Apply BREAKS
         myRigid.AddRelativeForce(Vector3.back * airBrakeForce);
         if(curSpeed <= decAltSpeed){
             myRigid.AddRelativeForce(Vector3.down * AnyNumberYouWant);
         }
         }
         
     }
     
     
     void Update(){
         //NOT REALISTIC ROTATIONS
         
         //You may have to move the '-' sign to the other one (- means opposite) E.G. - Negative so I THINK -Vector.up is left. Could be wrong though.
         
         if(Input.GetKey(KeyCode.A)){
             transform.rotate(-Vector3.up * 15 * Time.deltaTime);
             
         }
         if(Input.GetKey(KeyCode.D)){
             transform.rotate(Vector3.up * 15 * Time.deltaTime);
             
         }
     }
     
 }
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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

the flying script 1 Answer

Accelerometer Plane Controls help 0 Answers

Optimizing and generating terrain on mobile 1 Answer

how to make a plane model fly 1 Answer

Transform.position with Box Collider? 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