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. Dismiss Notice

Importing object to scene and make them collidable?

Discussion in 'Editor & General Support' started by adammil2000, Apr 15, 2014.

  1. adammil2000

    adammil2000

    Joined:
    Aug 25, 2013
    Posts:
    19
    Hi all,

    I am importing building models into my scene, but the imported structures they are not collidable like the ground and other objects already in the scene (the player avatar is walking right through them).

    What extra steps are needed to make these imported objects "solid" like they should be?

    Thanks!
     
  2. twiesner

    twiesner

    Joined:
    Oct 4, 2011
    Posts:
    309
    Add a collider. In the menu you can find it under component ->physics.
     
    petra02 likes this.
  3. adammil2000

    adammil2000

    Joined:
    Aug 25, 2013
    Posts:
    19
    In my case this is a hollow object (a house) with stairs up to the second floor. The colliding needs to occur on the house walls and the second story floor for example.

    Is a collider only for solid objects?
     
  4. twiesner

    twiesner

    Joined:
    Oct 4, 2011
    Posts:
    309
    You are probably going to have to break up your model into pieces. Separate the walls from the floor, stairs from the floor and walls, etc. Keeping it as one solid collider will create issues.
     
  5. SeveredScion

    SeveredScion

    Joined:
    Oct 16, 2012
    Posts:
    45
    Just found this thread. Not sure if you still need help since this was from months ago. But for the purposes of other people searching and finding this, here you go....

    The colliders provided by Unity are mostly pretty simple primitives. Any object that needs to interact physically with another object usually needs a collision model. For objects like hollow houses that need something more complex than a primitive, the collision model is often created in the same 3D model package as the main model. It is essentially a very simplified version of the model, that contains roughly the same volume and boundaries, but with none of the fine detail. The fewer polys/verts in the collision mesh, the less memory it uses, the faster the game runs.

    You could create this same thing by creating a bunch of mesh colliders in Unity, but depending on the object, it may be easier and quicker to create it in an outside 3D package and import it into Unity. Mesh colliders use more memory than Unity's default primitive colliders. However if it would take dozens of colliders to create a proper collision mesh, it may be more memory-efficient to import a separate collision mesh. Depends on the situation--experiment and find out.

    I believe the way to set an imported model as a collision model in Unity is:
    Add the model to be used for collision to a directory in your Unity project
    In Unity, select the object that needs collision
    In the Inspector, click add component-->physics-->mesh collider
    On the line that says Mesh that has a textbox saying "None (Mesh)" click the circle icon to the right and in the "select mesh" popup, choose the model to be used for collision

    There are other rules and guidelines for collision, some general, some specific to Unity. See more info in the following links:

    Unity documentation - mesh collider:
    http://docs.unity3d.com/Manual/class-MeshCollider.html
    Tutorial on collision basics in Unity:
    http://www.binpress.com/tutorial/unity-3d-collisions-basics/114
    Unity Answers - how do I supply a custom collision mesh?:
    http://answers.unity3d.com/questions/295015/how-do-i-apply-a-custom-collision-mesh.html
    Unity support forums - mesh guidelines:
    http://forum.unity3d.com/threads/mesh-guidelines.1626/

    Making a collision model can be considered a technical modeling task. Often this is done by the modeler, or maybe by engineers/programmers or other people working on the more technical side of development. As a modeler, I have sometimes but not always been asked to provide collision models.

    I hope this all helps collect information about collision meshes in Unity in a central location. Disclaimer: I'm a modeler, not a programmer/engineer, so if anyone with more technical knowledge than I has anything to correct or add, please do so.
     
  6. Falcon_X

    Falcon_X

    Joined:
    Feb 24, 2019
    Posts:
    1
    Found this helpful but may have an easier way.
    Once the model is in the assets, select the model
    In the Inspector under "Model" tab, under "Meshes" enable (check) the "Generate Colliders"
    It will take a few seconds to minutes depending upon the complexity.
    When the model is put into the scene it will have collisions.
     
    soulmwe, karangejo and donkenzaki like this.
  7. PinodA

    PinodA

    Joined:
    May 26, 2019
    Posts:
    1
    This is good but it will wrap a collider around the whole model, so if it is a room for example, you won't be able to get in it if coming from the outside.
     
    Joe-Censored likes this.
  8. StrawProductions

    StrawProductions

    Joined:
    Oct 11, 2020
    Posts:
    1
    Help! The add component isn't there, what should i do?
     
  9. karangejo

    karangejo

    Joined:
    Jun 6, 2019
    Posts:
    1
    This works and I have a very complex model that is hollow and has many different disconnected parts and this worked perfectly!