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!
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.
answered Nov 28, 2010 at 12:54 AM