Mesh collider unity что это
Перейти к содержимому

Mesh collider unity что это

  • автор:

Mesh Collider component reference

The Mesh Collider takes a Mesh Asset and builds its Collider An invisible shape that is used to handle physical collisions for an object. A collider doesn’t need to be exactly the same shape as the object’s mesh — a rough approximation is often more efficient and indistinguishable in gameplay. More info
See in Glossary based on that Mesh. It is more accurate for collision A collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a Rigidbody component and is in motion. More info
See in Glossary detection than using primitives for complicated Meshes. Mesh Colliders that are marked as Convex can collide with other Mesh Colliders.


Property Function
Convex Enable the checkbox to make the Mesh Collider collide with other Mesh Colliders. Convex Mesh Colliders are limited to 255 triangles.
Is Trigger Enable this checkbox to make Unity use this Collider for triggering events, and the physics engine A system that simulates aspects of physical systems so that objects can accelerate correctly and be affected by collisions, gravity and other forces. More info
See in Glossary ignore it.
Cooking Options Enable or disable the Mesh cooking options that affect how the physics engine processes Meshes.
None Disables all of the Cooking Options listed below.
Everything Enables all of the Cooking Options listed below.
Cook for Faster Simulation Makes the physics engine cook Meshes for faster simulation. When enabled, this runs some extra steps to guarantee the resulting Mesh is optimal for run-time performance. This affects the performance of the physics queries and contacts generation. When this setting is disabled, the physics engine uses a faster cooking time instead, and produces results as fast as possible. Consequently, the cooked Mesh Collider might not be optimal.
Enable Mesh Cleaning Makes the physics engine clean Meshes. When enabled, the cooking process tries to eliminate degenerate triangles of the Mesh, as well as other geometrical artifacts. This results in a Mesh that is better suited for use in collision detection An automatic process performed by Unity which determines whether a moving GameObject with a Rigidbody and collider component has come into contact with any other colliders. More info
See in Glossary and tends to produce more accurate hit points.
Weld Colocated Vertices Makes the physics engine remove equal vertices in the Meshes. When enabled, the physics engine combines the vertices that have the same position. This is important for the collision feedback that happens at run time.
Use Fast Midphase Makes the physics engine use the fastest mid-phase acceleration structure and algorithm available for your output platform. When you enable this option, the physics engine uses a faster algorithm that doesn’t require any R-Trees for spatial access. If you encounter mid-phase issues at runtime on some platform, you can still disable this option to use the slower legacy mid-phase algorithm instead.
Material An asset that defines how a surface should be rendered. More info
See in Glossary
Reference to the Physics Material that determines how this Collider interacts with others.
Mesh The main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary
Reference to the Mesh to use for collisions.


The Mesh Collider builds its collision representation from the Mesh attached to the GameObject The fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary , and reads the properties of the attached Transform to set its position and scale correctly. The benefit of this is that you can make the shape of the Collider exactly the same as the shape of the visible Mesh for the GameObject, which creates more precise and authentic collisions. However, this precision comes with a higher processing overhead than collisions involving primitive colliders (such as Sphere, Box, and Capsule), so it is best to use Mesh Colliders sparingly.

Faces in collision meshes are one-sided. This means GameObjects can pass through them from one direction, but collide with them from the other.

Details about underlying algorithms and data structures used by mesh colliders can be found at PhysX documentation.

Mesh cooking

Mesh cooking changes a normal Mesh into a Mesh that you can use in the physics engine. Cooking builds the spatial search structures for the physics queries, such as Physics.Raycast, as well as supporting structures for the contacts generation. Unity cooks all Meshes before using them in collision detection. This can happen at import time (Import Settings > Model > Generate Colliders) or at run time.

When you generate Meshes at run time (for example, for procedural surfaces), it’s useful to set the Cooking Options to produce results faster, and disable the additional data cleaning steps of cleaning. The downside is that you need to generate no degenerate triangles and no co-located vertices, but the cooking works faster.

If you disable Enable Mesh Cleaning or Weld Colocated Vertices, you need to ensure you aren’t using data that those algorithms would otherwise filter. Make sure you don’t have any co-located vertices if you have disabled Weld Colocated Vertices, and when you enable Enable Mesh Cleaning, make sure there are no tiny triangles whose area is close to zero, no thin triangles, and no huge triangles whose area is close to infinity.

Note: When you set the Cooking Options to any other value than the default settings, it means the Mesh Collider must use a Mesh that has an isReadable value of true .


There are some limitations when using the Mesh Collider:

GameObjects that have a Rigidbody A component that allows a GameObject to be affected by simulated gravity and other forces. More info
See in Glossary component only support Mesh Colliders that have Convex option enabled: the physics engine can only simulate convex mesh colliders.

For a Mesh Collider to work properly, the Mesh must be read/write enabled in any of these circumstances:

  • The Mesh Collider’s Transform has negative scaling (for example, (–1, 1, 1)) and the Mesh is convex.
  • The Mesh Collider’s transform is skewed or sheared (for example, when a rotated transform has a scaled parent transform).
  • The Mesh Collider’s Cooking Options flags are set to any value other than the default.

You should not modify mesh geometry that is used for colliders because the physics engine has to rebuild an internal mesh collision acceleration structure every time you change the mesh. This causes a substantial performance overhead. For meshes that need to collide and change at runtime, it is often better to approximate the mesh shape with primitive colliders like capsules, spheres and boxes.

Optimization tip: If a Mesh Collider only uses a Mesh, you can disable Normals The direction perpendicular to the surface of a mesh, represented by a Vector. Unity uses normals to determine object orientation and apply shading. More info
See in Glossary in Import Settings, because the physics system doesn’t need them.

Updated Mesh Collider limitations in 2018.3

2018–10–12 Page amended

Mesh Cooking Options added in 2017.3 NewIn20173

Updated functionality in 2018.1

Updated limitations relating to read/write enabled setting in 2017.3

Inflate Convex Mesh deprecated in 2018.3 because the new convex hull computation algorithm (Quickhull) is more tolerant towards imperfections in the input mesh.

Меш-коллайдер (Mesh Collider)

Mesh Collider использует меш ассет для создания под него коллайдера на основе этого меша. Это гораздо удобнее, чем использовать примитивы для определения столкновений сложных мешей. Меш коллайдеры, которые помечены как Convex могут взаимодействовать (сталкиваться) с другими меш коллайдерами.


Свойство: Функция:
Is Trigger Если включён, то этот коллайдер будет игнорироваться физическим движком и использоваться для запуска событий.
Material Ссылка на физический материал, который определяет, как данный коллайдер взаимодействует с другими.
Mesh Ссылка на меш, используемый для столкновений.
Convex При включении, текущий меш коллайдер будет взаимодействовать с другими меш коллайдерами. Выпуклые (Convex) меш коллайдеры ограничены 255 треугольниками.


The Mesh Collider builds its collision representation from the Mesh attached to the GameObject, and reads the properties of the attached Transform to set its position and scale correctly. The benefit of this is that the shape of the collider can be exactly the same as the shape of the visible mesh for the object, resulting in more precise and authentic collisions. However, this precision comes with a higher processing overhead than collisions involving primitive colliders (sphere, box, capsule) and so it is best to use Mesh Colliders sparingly.

Меши, служащие для расчёта столкновений, используют отсечение невидимых поверхностей. Если объект столкнётся с таким мешем визуально, то он также столкнётся с ним и физически.

Есть кое-какие ограничения в использовании меш коллайдеров. Обычно два меш коллайдера не могут столкнуться друг с другом. Все меш коллайдеры могут сталкиваться с примитивными коллайдерами. Если ваш меш помечен как Convex , то он сможет сталкиваться с другими меш коллайдерами.

Note that versions of Unity before 5.0 had a Smooth Sphere Collisions property for the Mesh Collider in order to improve interactions between meshes and spheres. This property is now obsolete since the smooth interaction is standard behaviour for the physics engine and there is no particular advantage in switching it off.

Mesh collider unity что это

Are we recording?

Meow Cam


What are properties?

  • A convenient way of providing encapsulation for your fields


What is a delegate?

  • A reference type variable that can hold a reference to one or more methods


What is a coroutine?

  • Special methods that can be executed over several frames by the engine

Collision vs Physics

  • Collision is whether two objects intersect
  • Physics for our purposes is collision + applied force


They are the objects that we will be applying physics on. You can think of them as sets of triangles (or vertices, edges and faces). In unity we use meshes with the Mesh Filter and Mesh Renderer component.


Quick blender demo

Bounding Volumes

Simple shapes that completely contain an object. Used for optimizing collision detection. The most popular bounding volumes are bounding boxes, spheres and capsules.

Boxed Suzanne

Suzanne in a sphere

Axis Aligned Bounding Box

Bounding Spheres

Bounding Volume Hierarchies

A tree structure of bounding volumes. Can make the time complexity of the collision detection algorithm logarithmic in the number of objects.

Suzanne Hierarchy

Colliders 3D

  • Unity’s implementation of 3D bounding volumes
  • Invisible in Game View
  • GameObjects can have multiple colliders (compound colliders)
  • Examples:
    • Box Collider
    • Sphere Collider
    • Capsule Collider

    Colliders 2D

    • Unity’s implementation of 2D bounding volumes
    • Are incompatible with 3D colliders
    • Work in a separate 2D Physics Engine
    • Examples:
      • Box Collider 2D
      • Circle Collider 2D
      • Capsule Collider 2D
      • Polygon Collider 2D

      Mesh Colliders

      If even compound colliders don’t offer enough precission then we can use Mesh Colliders to match the shape of the GameObject’s mesh exactly.

      Suzanne Mesh Collider


      Mesh Colliders don’t collide with other Mesh Colliders. For that to happen we need to make them into convex hulls.


      By default colliders work for physics. To make them work just for collision we have to make them triggers. In scripts we work with triggers differently.

      F ixed U pdate

      • The framerate independent version of Update
      • Called 50 times a second
      • Use Time .fixedDeltaTime instead of Time .deltaTime
      • Used for physics calculations


      • Unity’s implementation for 3D physics
      • Applies physical forces on a GameObject based on its colliders
      • Allows modification of gravity
      • Has properties like Mass and Drag

      RigidBody in action

      RigidBody Code


      • Unity’s implementation for 2D physics
      • Provides the same functionality in 2D that the Rigidbody component provides in 3D
      • Is incompatible with the regular Rigidbody
      • Works in a separate 2D Physics Engine

      Static Colliders

      When a GameObject has a collider but doesn’t have a RigidBody

      • Used for motionless objects
      • Don’t change their transform because that could cause errors in the physics engine!
      • Example usage:
        • Ground Terrain
        • Buildings
        • Walls

        Physics Materials

        • Can give additional properties to colliders like friction and bounciness

        Kinematic Rigidbody Collider

        Controls whether physics affects the rigidbody

        • Example usage:
          • Sliding Doors
          • Traps

          Physics Loop — Collisions

          Physics Loop — Triggers

          Physics Layers

          • Every GameObject belongs to a Physics Layer
          • We can define our own custom physics layers
          • Can be used in Raycast LayerMasks
          • We can customize which layer can collide with which other layer:
            Edit/Project Settings/Physics/Layer Collision Matrix

          Raycasting 3D

          Cast a ray from some point in some direction and return information on what was hit

          Level Design in Unity 3D Part 6: Colliders

          Jared Amlin

          Colliders are working behind the scenes in most games that you play. Unless you want your player to be able to walk through walls, or fall thorough the ground unintended, adding colliders to your game scene is the way to go.

          Lets start adding colliders to this science fiction game environment that I have been assembling with assets from Filebase. Create a new empty object and call it…

          Jared Amlin

          Written by Jared Amlin

          I am an artist and musician, that is currently diving headfirst into game development with C# and Unity3D.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *