• 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 riku989jtb · Apr 28, 2012 at 04:29 PM · character controllerflyingflight

Character Flight

I have been trying to find/make a character controller & script that give my player the ability to fly but nothing is working....... could someone help me out please? (I'd really apprieciate it) :)

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 Lo0NuhtiK · Apr 28, 2012 at 04:36 PM 1
Share

Lets see some of your code from of all the different ways you've already tried making it work. Then maybe someone can tell you where you're going wrong with it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by riku989jtb · Apr 28, 2012 at 07:42 PM

This is my latest attemp but this one along with the others dont work that well

function Update () { }

//Speed Variable unstable above 25

var speed = 6.0;

var airspeed = 5.0;

var jumpSpeed = 8.0;

var gravity = 20.0;

private var moveDirection = Vector3.zero;

private var grounded : boolean = false;

function FixedUpdate() {

 if (grounded) {

    // We are grounded, so recalculate movedirection directly from axes

    moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

    moveDirection = transform.TransformDirection(moveDirection);

    moveDirection *= speed;      

      if (Input.GetButton ("Jump")) {

      moveDirection.y = jumpSpeed;

      }

    }

    else {



    //Preserving fall value

    var fall = moveDirection.y;





    var NewmoveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

    NewmoveDirection = transform.TransformDirection(NewmoveDirection);

    moveDirection = moveDirection + ((NewmoveDirection * airspeed) * Time.deltaTime);







    //Replacing Y movement value to original fall

    moveDirection.y = fall;

    }



 // Apply gravity

 moveDirection.y -= gravity * Time.deltaTime;



 // restrict to speed and Move the controller

 moveDirection.x = Mathf.Clamp(moveDirection.x, -speed, speed);

 moveDirection.y = Mathf.Clamp(moveDirection.y, -speed, speed);

 moveDirection.z = Mathf.Clamp(moveDirection.z, -speed, speed);

 var controller : CharacterController = GetComponent(CharacterController);

 var flags = controller.Move(moveDirection * Time.deltaTime);

 grounded = (flags & CollisionFlags.CollidedBelow) != 0;

 }



 @script RequireComponent(CharacterController)
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 Mickman · Jun 09, 2012 at 11:19 AM 0
Share

any progress with the flight mode ? I am interested in creating a character with parachute

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

how can I make a character fly when holding down the jump button? 1 Answer

3rd person Flying with Collision problems 1 Answer

Character "flying" when moving 2 Answers

Third person controller in Flight 1 Answer

Rigidbody + Character Controller = flight? 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