- Home /
Equivalent to Character Controller for Quadrupeds
Hi all,
The player character in our game is a wolf and he has to navigate a Unity terrain with hills, rocks and trees etc. Since we can't rotate the character controller, what is the recommended method for putting a collider on a quadruped?
At the moment we're using the FPSWalker script to move the character around. We'd like to keep the same functionality, so i'm guessing we have to use something like a box collider and write a custom script? This shouldn't be a problem, but i'm thinking there might be issues when going up/down slopes, so maybe something like a capsule collider would work better?
I'd be keen to hear how other people have approached this.
Thanks.
Answer by Cyclops · May 16, 2010 at 03:53 PM
Are you aware of the Locomotion System? As far as I know, it also works with quadrupeds.
Update: the Documentation says:
- Ground Hugging for Non-Bipeds
Creatures with more than two legs support their weight differently than humans and other bipeds. The Locomotion System has two simple settings to handle that [...].
and includes a Coyote model for example.
Hi Cyclops, thanks for the suggestion. I knew about the Locomotion System but it completely slipped my $$anonymous$$d lately!=S I didn't know if it could be used with quadrupeds though, i'll have a play with it tonight and report back. Cheers.
Brilliant! I feel really silly now since our tutor at uni was running around with a coyote but I thought it was a tech demo he'd found online, I didn't realise it was part of the Locomotion System. Sheepishly slinking away now, silly me.
Whoops! Consider yourself upvoted;-) I'll complete the question once I implement the Locomotion System tonight. Thanks again.
Answer by jester · Apr 30, 2010 at 10:45 PM
i haven't used the character controller yet but my first thought would be to try two sphere colliders, one set to cover the hind legs/body and one for the front legs/body. drive the wolf by moving the forward collider and then let the rear one just follow along, possibly attached by a very stiff spring. that should keep the rear legs from falling through terrain and orient them properly when going up/down hills. swap ccontrol to the rear legs if you want him to be able to walk backwards.
Thanks jester, that's an interesting solution I hadn't considered. I messed around with box colliders and capsule colliders yesterday (adding a rigidbody to quickly get collision going, with comical results!), but I still had the problem of aligning the wolf to the terrain properly. I'll attempt your method when I get a chance and report back. Thanks.
$$anonymous$$ake sure to work out the CC collider center, so you can move the collider up or along the X and Z axes. This helped me a lot. Check out my answer regarding what I did to solve the collider...although is not the perfect solution, it might help you.
Answer by Arbbot · May 26, 2010 at 07:55 PM
Hi all,
Great information, but the Locomotion System actually used the default Character Controller with the default capsule collider. If you download the project and add a cube in the scene, you will notice that you can stick the Coyote's head into the cube.
After digging all around the Internet, including Unity official forums and answers, and even Thesis studies of Computer Animation Graphics using Unity, it seems that there's no way around the Character Controller default Capsule Collider. Either you don't use it at all, and use a primitive collider and create your own scripts, or use the default Character Controller.
Now the trick that kind of works, is to modify the default capsule collider to be very high and have the radius cover your model mesh. You need to make sure the capsule's height is high, otherwise characters will be able to walk over the CC capsule. This way you get better side collisions, sacrificing top collisions precision.
Let's hope that in Unity 3 we can modify the capsule to make different shapes, to match not only humanoid forms, but also animals and crazy shaped creatures.
Cheers!