Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Character Clipping through Enclosed Mesh

Discussion in 'Physics' started by Lhurgoyf, May 13, 2018.

  1. Lhurgoyf


    May 5, 2018
    5.6.3p2 Personal on a 2015 MacBook (usable for editing simple stuff in Unity, amazingly)
    Using C#
    Hello, Unity World. I am a somewhat good programmer and have been figuring out how to use Unity over the past several months. So, recently I set up a *very* basic scene. It consists of a capsule collider for the player, a camera parented to the capsule, the default lights, and a map (an FBX exported from Unity.) The Player script uses a **very** basic top-down controller (changed a bit from a tutorial on YouTube.) My problem is clipping. The player controller moves up, down, left, and right with WASD, but when it collides with the map for long enough, it clips through the walls as shown in the video linked to on Google Drive below.

    TL;DR I am using a basic RigidBody capsule character controller that has worked in the past that now clips through the map of my scene, which uses a mesh collider. What may be causing the clipping, and how might I be able to fix it?

    Thank you so much for your help.

    ZIP with project along with video of the problem

    //The top-down character controller.
    using UnityEngine;
    using System.Collections;

    public class TopDownController : MonoBehaviour

    public float speed = 10.0F; //How fast the character moves

    // Use this for initialization
    void Start()
    Cursor.lockState = CursorLockMode.Locked; //The cursor can't move


    // Update is called once per frame
    void Update()

    float translation = Input.GetAxis("Vertical") * speed;
    float strafe = Input.GetAxis("Horizontal") * speed;
    translation *= Time.deltaTime;
    strafe *= Time.deltaTime;

    transform.Translate(strafe, 0, translation);

    if (Input.GetKeyDown("escape")) {
    /*Holding escape makes the cursor
    * able to move outside of the game*/
    Cursor.lockState = CursorLockMode.None;