CharacterController gets stuck between two or more box colliders
I recently started testing with CharacterControllers and am finding bugs where my 'player' gets stuck between 2 box colliders (with scale <1, 1, 1>). My purpose is to make the player slide past them.
Possible solutions I've found so far:
Tweak the box colliders of the 'walls' or 'barriers' so that their collider's scale are between 0.97 and 0.95 - The main problem is that the player overlaps with the collider, something I want to avoid.
Do the same but instead of every wall make it the player - Same issue. Glitchy collisions.
I have to state that I'm not directly managing collisions - The gravity is applied via the CharacterController attached to the player.
Information
Gizmos of the box colliders
The player properties
Properties of the physics material (Slimey)
Dynamic Friction: 0
Static Friction: 0
Bounciness: 0
Friction Combine: Minimum
Bounce Combine: Minimum
Code on the PlayerController script
using UnityEngine; using System.Collections; public class PlayerController : MonoBehaviour { public float speed = 6.0F; public float jumpSpeed = 8.0F; public float gravity = 20.0F; private Vector3 moveDirection = Vector3.zero; public Transform target; // 1 void Update() { CharacterController controller = GetComponent<CharacterController>(); if ( controller.isGrounded ) { moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= speed; if ( Input.GetButton("Jump") ) moveDirection.y = jumpSpeed; } moveDirection.y -= gravity * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime); } }
CharControllers are really meant to use the capsule collider they come with. Adding another collider (like the box collider you added around it) just confuses them. Lots and lots and Qs and replies here about that -- mostly adding an extra collider, like a ball in front.
I changed the box colliders for capsule colliders and they seem to be working. Thank you Owen.