2
\$\begingroup\$

I've made it so that all entities have complex box colliders for hit detection purposes. These entities also have character controllers on them. The problem? Gravity, or lack thereof. When the character controller is of a certain size, gravity doesn't work. However, if you set it to a bigger size, one way too big to be usable, suddenly gravity works as expected.

I'm looking for one of two things: either a way to make character controllers work, or a way to replace character controllers and everything that they're dictating (movement, as well as gravity.) I've looked into using Rigidbodies, but the character falls to the ground (woo) and flops about on the floor on its back (not such a woo moment.)

I'm open to using Rigidbodies if that's the only alternative, but if you could point me to a good guide on how exactly to use them for players, I would appreciate it.

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

I'm not sure how you are getting the behavior you are getting with Character Controllers and gravity. By default, there is no concept of "gravity" with a character controller. This is something that must be implemented through code.

To work with a Character Controller, you should use the CharacterController.SimpleMove or the CharacterController.Move methods of the character controller. A good example of this comes straight from the Unity documentation for CharacterController here:

http://docs.unity3d.com/ScriptReference/CharacterController.Move.html

This will also cover setting up gravity for a CharacterController.

As far as CharacterController versus Rigidbody characters, it really depends on what kind of game you are trying to build. A CharacterController is good for nice tight movement and controls. These are often used in FPS shooter games. RigidBody's for characters are used if you want the physics engine to interact with your character. This is done by applying forces to the character.

There are a few helpful links that will show you when and why you would use a CharacterController versus a RigidBody on a character:

http://answers.unity3d.com/questions/7671/guidelines-for-using-rigidbody-collider-characterc.html

There is also a Youtube video that goes into more depth about this. Search for "Unity 3D - Rigidbody VS CharacterController [UnityQuickTips]" on youtube.

\$\endgroup\$
2
  • \$\begingroup\$ Hello BrianGameDev, thanks for your response and time! What I failed to explain (apologies) is that right now, there's a Character Controller component on the entity, and through script, a sense of gravity is being created. From what you're saying, it may be the code creating the sense of gravity that may be off? It looks like I'm using the .Move to apply gravity, as well as all other movement. Should gravity be separate? I'll definitely look into that video, thanks! And thanks again for your time, and apologies for not being clearer in my original post! \$\endgroup\$
    – Hypocrita
    Feb 14, 2015 at 19:46
  • \$\begingroup\$ It must be the logic for moving the CharacterController or the logic you are using for gravity. The first link I sent you should show a basic example that you can build from. Good luck! \$\endgroup\$ Feb 24, 2015 at 4:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .