• 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
1
Question by n8 · Nov 12, 2010 at 05:40 PM · rigidbodyiphonecharactercontrollerwalkingflight

Best method for making a character that has the ability to fly and walk

As the title suggests I am trying to create a character that can both walk and fly throughout the game world. I am trying to figure out the most perfomant way to do this as it will be running on the iphone.

My first attempt was to use a standard character controller and just add some simulated physics that would allow the character to fly. This works for the most part seeing as the character controller is built for walking. However when flying, i didn't have any real control over the rotation of the character (it is very possible i am just missing some method for rotating the character controller). So with this method i could not easily control the character in the air such as flying straight up/down. Also having the character bank in mid-air required an animation being triggered to simulate the character banking. this gave a very awkward look to the whole thing.

My second attempt was with rigidbodies. I have a nice flight script that solves all of my flight problems from above. The problem here is walking. I tried using the rigidbodieFPS script from unify-community in conjunction with a switch script that would handle activating/deactivating either the walker or flyer depending on where the character is. but the character did not look good walking at all (always facing one direction, despite what direction it was actually moving). Once again i could be missing something here that would make it work better.

So my question is if there is a better method to this? is there some magic way to make a character controller and rigidbody play nice with each other? Thanks in advance for any advice or help!

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

2 Replies

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

Answer by Bravini · Nov 28, 2010 at 12:54 AM

1 - you could have the objects with the walk and fly script on the same object and turn on/off the righ script with static variables. 2- Instantiate the right script and destroy the other.

What seens to work better for me is the 1st solution, have both scripts on the object and disable the one not correctly being used. While flying, you don't need gravity(set it to 0) or rigidbody functions ,so turn off the rigidbody. While walking, gravity applies normally and you can push objects.

Comment
Add comment · Show 3 · 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 n8 · Nov 29, 2010 at 03:55 PM 0
Share

this is pretty much what i am doing now. I tried putting both a rigidbody and a character controller on the player and set the rigidbody to "Is $$anonymous$$inematic" - false when walking and true when flying. I have a script that will enable/disable the appropriate walk/fly script based on if the character is grounded or not. this seems to work pretty well for getting the player to walk effectively, however it seems that the character controller is screwing with my flight script. When flying everything seems real slow and "laggy".

avatar image Bravini · Nov 29, 2010 at 04:36 PM 0
Share

I believe this is the same issue that happens if you try to put a character controller and a rigidbody to a capsule then add the fpswalker. Try disabling the character controller too and using a movement script ins$$anonymous$$d when flying, or if you can post your scripts ,I can try testing it and give you a better response.

avatar image n8 · Nov 29, 2010 at 05:37 PM 0
Share

I believe you are right. Problem is that character controller has no "enable/disable" switch like other components. I guess i will have to resort to the hacky destroy/instatiate to get this working.

avatar image
1

Answer by The_r0nin · Nov 26, 2010 at 08:26 PM

I had a similar issue myself with multiple modes of travel and multiple meshes. It seems that it would be easier in your case, since you can use the same mesh. Hopefully what I figured out for my game will help you a little...

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.

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

No one has followed this question yet.

Related Questions

Physics with CharacterController? 1 Answer

Character stucks always (Rigidbody/Character) 0 Answers

How to check rigid body vector movement? 0 Answers

Character Sliding before animation starts 1 Answer

Rigid body with moveDirection 0 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