x


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!

more ▼

asked Nov 12, 2010 at 05:40 PM

n8 gravatar image

n8
207 33 28 48

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Nov 28, 2010 at 12:54 AM

Bravini gravatar image

Bravini
1.1k 17 20 47

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 Kinematic" - 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".

Nov 29, 2010 at 03:55 PM n8

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 instead when flying, or if you can post your scripts ,I can try testing it and give you a better response.

Nov 29, 2010 at 04:36 PM Bravini

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.

Nov 29, 2010 at 05:37 PM n8
(comments are locked)
10|3000 characters needed characters left

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...

more ▼

answered Nov 26, 2010 at 08:26 PM

The_r0nin gravatar image

The_r0nin
1.5k 27 27 47

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3172
x2230
x1175
x131
x75

asked: Nov 12, 2010 at 05:40 PM

Seen: 3184 times

Last Updated: Nov 26, 2010 at 07:16 PM