Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Character controller goes crazy when close to mesh collider

Discussion in 'Physics' started by kubazz, Jun 18, 2015.

  1. kubazz

    kubazz

    Joined:
    Nov 20, 2013
    Posts:
    5
    Hi, I'm Kuba working on www.superhotgame.com. Since we switched to Unity 5 we're having constant problems with character controller behaviour. The biggest issue are wrongly detected collisions with mesh colliders (both convex and concave).

    Illustrated with simple gif (Unity 5.1.1f1):


    The camera gizmo represents out player getting close to an object. The object has both mesh collider used for dectection of bullet collisions and additional box collider for player collision. I debugged for a bit and player controller is NOT colliding with internal mesh collider, only with bigger box collider, but still as you can see player gets thrown in the air for no apparent reason. Changing internal collider to box collider or turning it off completly fixes the issue but is is unacceptable workaound for us, as in our game proper collision of bullets with enviroment is essential gameplay mechanic (you can play the prototype on our website to understand why).
    At the moment our workaround is using lot of simple colliders for every prefab, which is very time-consuming to setup and produces worse results as you can often see that bullet collided where is should not.
    I can confirm that in Unity 4 everything was working properly. We're not afraid of concave mesh colliders cost as our levels are fairly compact and in Unity 4 we did not have any kind of perfomance issues.
     
  2. HiddenMonk

    HiddenMonk

    Joined:
    Dec 19, 2014
    Posts:
    987
    It is hard to see what is going on with the gif you provided. I am not able to see the player, was that intended? (A youtube video might be better)

    Maybe it is similar to the problem here
    http://forum.unity3d.com/threads/pr...ler-and-mesh-colliders-in-unity-5-0-1.320516/
    When the character controller goes into the collider, it now ejects out instead of staying in. Maybe you were always penetrating into the object and now in unity 5 you are actually seeing it.

    I see people here also getting bad results saying things are affecting their character controllers in unity 5
    http://answers.unity3d.com/questions/941860/unity-4-to-5-character-controller-issue.html

    I also see this post saying how there can be issues if there are any other colliders with the character controller, including children objects.
    http://forum.unity3d.com/threads/character-controller-possible-bug.279762/
    Maybe the mesh collider causes issues with a child collider of yours which causes issues with your character controller. Its a stretch, but possible I guess ;)


    You say that your "player controller is NOT colliding with internal mesh collider", so how do you know the problem is with the character controller? Are you doing any raycasts that affect the players movement? What else affects your players collision?

    What is your fixedtimestep at, and what is your default contact offset? Does decreasing any of these make things better (not saying this is a good solution, but might help with debugging)

    Just spitting out things to check =)
     
    Last edited: Dec 20, 2016
  3. kubazz

    kubazz

    Joined:
    Nov 20, 2013
    Posts:
    5
    There is camera gizmo at player position, you can see it jumping when I move player close to the object. (gif was recorded from scene view).

    I have seen those threads before, our problem seems to be related. I hope this issue gets more recognition at Unity and gets resolved as soon as possible.

    Moving box collider outside of prefab's hierarchy was my first idea, didn't work unfortunately :(

    I was spitting out Debug.Logs containing names of objects that player collides with - there not a single collision between mesh collider and character controller, yet it's presence caused player controller to behave improperly. Other objects (using simpler colliders) in our game collide with mesh colliders without any issues.

    I managed to prepare very simple sample project in which only character controller collisions impact player's position and I could reproduce similiar issue there (player did not get thrown into air, but was stuck instead).

    Our fixed timestep is 0.008 and default contact offset is 0.01. Skin width of character controller is 0.05. I tried messing up with those values, no luck so far.

    Well, at least I know that I was trying right things ;)

    As have been trying to pin down this issue for last weeks in my free time, now I'm pretty sure that it's engine / physics engine bug. I have submitted bug report with sample video and sample project: http://fogbugz.unity3d.com/default.asp?705730_qkbj6d6vli9iuonl
     
  4. HiddenMonk

    HiddenMonk

    Joined:
    Dec 19, 2014
    Posts:
    987
    I guess only the unity developers can see the scene in the bug report? Would you want to post it here too, or does it have things in it you dont want the public to see? If so, then I understand =)
    I have a lower version of unity 5, I wonder if the bug would also be in this version (if it is a bug).

    If you use the unity standard asset character first person controller, does the problem still happen? I tried setting something up similar to what I saw in the video in my unity version 5.0.2f and I dont seem to be getting stuck.
     
    Last edited: Jun 19, 2015