Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

First Person Prefab falls through imported Terrain Model

Discussion in 'AR/VR (XR) Discussion' started by astrojared, Jun 5, 2017.

  1. astrojared

    astrojared

    Joined:
    Jan 7, 2017
    Posts:
    15
    Hi all,

    I'm having a bit of trouble with imported terrain data - it first person controller falls straight down through it, even when I make sure that it was placed right above the model.

    When I first imported the model it looked transparent with orange outlines of the tiles the terrain was broken into, and after adding a solid white material to it, the character still falls through. I added a video to show what happens:


    I'm experienced with Unity, and any pointers in the right direction would help tremendously! I'm guessing it might have something to do with an object type.
     
    Last edited: Jun 5, 2017
  2. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Have you added a mesh collider?
     
  3. astrojared

    astrojared

    Joined:
    Jan 7, 2017
    Posts:
    15
    I saw that around, but couldn't find it in the Standard Assets. I'll look for it in the store and get back tomorrow morning.
     
  4. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
  5. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    A mesh collider is just one of the components that is in normal Unity (not an add on in standard assets). Simply click on Add Component and then I believe it's Physics -> mesh collider. It's been a long time since I used the fpscontroller I believe it was actually a capsule collider on it.

    But in general the only thing that is required is that there is some collider on both the character and the ground and that they don't start overlapping (usually best to give a small buffer). If you weren't using the character controller you'd probably also want a rigidbody on it but with a character controller it isn't necessary.

    https://unity3d.com/learn/tutorials/topics/physics/colliders?playlist=17120 (character controllers by default don't use physics so a rigidbody isn't necessary just the colliders)

    https://unity3d.com/learn/tutorials/topics/physics/rigidbodies (if you ever want it to be actually physics driven)
     
    wcoastsands likes this.
  6. astrojared

    astrojared

    Joined:
    Jan 7, 2017
    Posts:
    15
    Many thanks for your responses!

    I added both a mesh and a terrain collider to the ground, but my user still feel straight through my terrain. Is there anything else I could be doing wrong?

    I also attached a screenshot with my inspector
     
    unity_V16sPb0I8SVOuw likes this.
  7. astrojared

    astrojared

    Joined:
    Jan 7, 2017
    Posts:
    15
    Alas I forgot the screenshot
     

    Attached Files:

  8. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    You need to add the Mesh Collider to a gameobject that has the Mesh Filter of your Terrain's 3d model.

    Don't worry about adding Terrain Collider, because you're not using Unity's built-in terrain.
     
  9. astrojared

    astrojared

    Joined:
    Jan 7, 2017
    Posts:
    15
    Sorry for the slow response - I ended up on a different project for a while.

    The main concern I have is that I'm not sure which mesh to apply the Mesh Filter to - I have a bunch of mini-meshes it looks like. I attached a screenshot of my dilemma.

    And thanks for your responses!
     

    Attached Files:

  10. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Each one will need a mesh collider, and the mesh collider should match the one you see on the mesh filter.
     
    astrojared likes this.
  11. BamBamAlicious

    BamBamAlicious

    Joined:
    Jan 29, 2017
    Posts:
    58
    You need to have a collider on both the terrain AND the player model as well. Make sure you have isKinematic off on the player RigidBody too!
     
    astrojared likes this.
  12. astrojared

    astrojared

    Joined:
    Jan 7, 2017
    Posts:
    15
    I added a mesh collider both my material and my FPS controller, but still fall through in the same manner as before. Should I add a material?
     

    Attached Files:

    unity_V16sPb0I8SVOuw likes this.
  13. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    In the original video, the player has a "CharacterController" so a rigidbody is not required on the player.

    As per the new png image, I would think that a CharacterController would not fall through that gameobject, Unless there is an error in the console about "Cannot use non-convex collider .... " error, OR the player's layer and ground layers are not set to have Physics interaction in Physics Settings (doubt that).

    So I don't know what the problem is !
     
  14. BamBamAlicious

    BamBamAlicious

    Joined:
    Jan 29, 2017
    Posts:
    58
    Another wild stab in the dark, could the terrain need to be static?
     
  15. landajason

    landajason

    Joined:
    Mar 1, 2019
    Posts:
    1
    I was having a similar problem with an imported terrain.(Glowing Forest). I added a mesh collider and changed cooking options to everything (making sure I had a rigid body on my object that I didn't want to fall through). Then I was able to add force or apply physics changes (I was testing a sphere with rigid body add force to move it (like the roll a ball tutorial).