I’ve imported a background object with mesh collider. Within the mesh collider, the material is set to None (Physic Material) and the Mesh reads ObjectName.
I’ve added a character controller to my character, but the collision isn’t being recognized.
What step am I missing?
Also, what are the correct collision settings for a ground object? Every time I add a Rigidbody, the objects fall through the floor.
Be sure to have a primitive collider on your object that is to collide with your mesh. I dont totally get it but just keep adding colliders until it works. I havent really had any luck with the character controller, so cant help you there. If things dont work how they should theres no harm in rebooting the program now and then
Your rigidbody is falling because you have to un-check use gravity in the inspector for the rigidbody component of your object, or check isKinematic which makes the rigidbody only move if you tell it to through scripting.
I don’t think rigidbody is what you want though. I haven’t used the character controller, but it should work fine with simple colliders. Are there any colliders on the character controller object? You might have to attatch primitive colliders to the various limbs of your character. Not sure, havent used it.
Hope that helps 'till someone can tell you exactly how to fix it.
-Jeremy
The Character Controller Prefab doesn’t use gravity, it uses scripting to simulate gravity by moving the character downwards until it hits a collider.
Your level mesh doesn’t need to have a rigidbody applied to it, it just needs to have a mesh collider applied. The Character Controller Prefab uses a Capsule collider that you can resize to encompass your character.
I’m not sure then. I’ve done a number of things with the Character Controller Prefab (FPS and third person) and have never run into the problem of it falling through the “floor”. Same with other meshes that have rigidbodies attached, they always properly fall to the ground. The only thing I can think of is that the physics engine does not allow two mesh colliders to collide together. All your rigidbody objects must use primitive colliders.
Are you trying to do an FPS or a third person game. If it’s the latter then you need to parent your character mesh to the Character Controller Prefab. Your character can’t have any rigids/colliders… that is all handled by the CCP and your child character just follows along.
My character controller doesn’t fall through the floor. That’s a separate issue.
I’m doing a third person game. I select the character and then add a dynamics/character controller. Is that what you mean by parenting the mesh to the prefab?
For the background object, when I import it, I select Mesh Collider.
The character will still move through the background object.
If I assign a rigidbody to the background object, it falls through the ground.
I’m sure I’m just missing a step or failing to tick off the right box…
No, you need to create the CCP and then make your character a child of that.
This has to do with the fact that two mesh colliders won’t physically interact. Don’t assign any rigidbody anything to your character mesh. The collisions are handled by the capsule collider in the CCP.
You are using the sample move script? I don’t think that uses the character controller at all, so it won’t do any collision detection. You need to use a script that actually uses the character controller.
The SampleMoveScript uses “Transform.Translate” to move the character. You need to use “CharacterController.Move”. You can try modifying the FPSWalker script (which is initially part of the First Person Controller Prefab), or look at the Goober character in the Character-Animation examples (1.5b) to see how it’s scripted there, or this Goober for another way to do a third person scene.