Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    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;