< Return to Video

Collider 2D - Official Unity Tutorial

  • 0:01 - 0:04
    Para tener cualquier presencia
    física en la escena
  • 0:04 - 0:06
    un objeto de juego debe tener un
  • 0:06 - 0:09
    componente colisionador para
    definir su forma física
  • 0:09 - 0:12
    y para interactuar con el
    motor físico relevante.
  • 0:13 - 0:15
    Unity tiene 2 motores físicos.
  • 0:15 - 0:18
    Uno para 3D y otro para 2D.
  • 0:18 - 0:22
    Estos dos motores físicos
    no interactúan entre si.
  • 0:23 - 0:26
    Para más información
    sobre física y física 2D
  • 0:26 - 0:28
    por favor, vea la
    información vinculada abajo.
  • 0:29 - 0:31
    Cuando se usa el motor físico 2D
  • 0:31 - 0:35
    un componente colisionador
    2D debe ser usado.
  • 0:36 - 0:39
    Existen 4 componentes
    colisionadores 2D para elegir.
  • 0:40 - 0:42
    El colisionador 2D circular,
  • 0:42 - 0:44
    el colisionador 2D caja,
  • 0:44 - 0:46
    el colisionador 2D poligonal
  • 0:46 - 0:49
    y el colisionador 2D de bordes.
  • 0:50 - 0:53
    Todos estos colisionadores
    comparten muchas propiedades
  • 0:53 - 0:55
    ya que todos derivan del mismo
  • 0:55 - 0:57
    colisionador base 2D genérico.
  • 0:58 - 1:00
    Cada componente colisionador
    2D sin embargo es
  • 1:00 - 1:02
    optimizado para una forma particular.
  • 1:03 - 1:05
    El colisionador 2D
    circular funciona
  • 1:05 - 1:07
    con objetos circulares.
  • 1:08 - 1:12
    El colisionador 2D caja funciona
    bien con objetos rectangulares.
  • 1:12 - 1:14
    El colisionador 2D poligonal funciona
  • 1:14 - 1:16
    mejor con formas complejas.
  • 1:17 - 1:21
    Y el colisionador 2D de bordes
    funciona bien con superficies.
  • 1:23 - 1:26
    El colisionador de bordes y el
    colisionador poligonal son muy similares.
  • 1:27 - 1:30
    Son creados por varios puntos, o vértices,
  • 1:30 - 1:32
    con bordes conectándolos.
  • 1:33 - 1:36
    La principal diferencia entre ellos
    es que el colisionador poligonal
  • 1:36 - 1:39
    debe ser una forma
    cerrada que cubre un área
  • 1:40 - 1:42
    Y el de bordes debe ser abierto,
  • 1:42 - 1:45
    definiendo un borde de
    uno o más segmentos.
  • 1:46 - 1:48
    Un buen uso del colisionador de bordes
  • 1:48 - 1:50
    es hacer una única superficie sólida
  • 1:50 - 1:53
    en vez de una serie de colisionadores 2D
  • 1:53 - 1:55
    aún si varios sprites
    son usados para crear
  • 1:55 - 1:58
    el aspecto visual de la superficie.
  • 2:00 - 2:02
    Cuando se compara todos
    los colisionadores 2D
  • 2:02 - 2:04
    hay 2 propiedades
    expuestas en el inspector
  • 2:04 - 2:06
    que todas comparten.
  • 2:06 - 2:09
    Is Trigger y Material.
  • 2:10 - 2:12
    Las otras propiedades
    únicas son el definir
  • 2:12 - 2:15
    la forma de ese colisionador
    2D particular.
  • 2:16 - 2:18
    La propiedad Is Trigger
    establecerá al colisionador
  • 2:18 - 2:20
    para comportarse como
    un colisionador disparador.
  • 2:21 - 2:23
    With normal 2D physics collisions
  • 2:23 - 2:25
    the 2D physics engine will prevent
  • 2:25 - 2:28
    2D colliders from passing through each other.
  • 2:30 - 2:32
    2D trigger colliders will not participate
  • 2:32 - 2:35
    in physical collisions and will send 2D
  • 2:35 - 2:39
    trigger messages rather than 2D collision messages.
  • 2:39 - 2:41
    These trigger messages can be used to
  • 2:41 - 2:44
    initiate new actions in the scene.
  • 2:45 - 2:47
    For more information on Is Trigger
  • 2:47 - 2:49
    and the messages sent by colliders
  • 2:49 - 2:51
    please see the information linked below.
  • 2:53 - 2:56
    The material property is a reference to the
  • 2:56 - 3:00
    physics material 2D being used by the collider 2D
  • 3:00 - 3:02
    and this can be none.
  • 3:02 - 3:04
    Physics materials define how colliders
  • 3:04 - 3:06
    will react when they collider
  • 3:06 - 3:08
    and define both the bounciness and
  • 3:08 - 3:10
    the friction of the collider's surface.
  • 3:11 - 3:15
    To make a bouncy ball or slippery ice covered platform
  • 3:15 - 3:17
    use a different physics material 2D
  • 3:17 - 3:19
    with each collider 2D.
  • 3:20 - 3:23
    For more information on physics material 2D
  • 3:23 - 3:26
    please see the information linked below.
  • 3:27 - 3:30
    To use a collider 2D it must be attached
  • 3:30 - 3:32
    to a game object.
  • 3:32 - 3:35
    One way of attaching a collider 2D component
  • 3:35 - 3:37
    is to use the Add Component button
  • 3:37 - 3:39
    and select Physics 2D
  • 3:39 - 3:42
    and select a Collider 2D Component.
  • 3:43 - 3:45
    For more information on game objects,
  • 3:45 - 3:47
    components and how to use them
  • 3:47 - 3:50
    please see the information linked below.
  • 3:51 - 3:53
    When a collider 2D component is attached
  • 3:53 - 3:57
    Unity will try to size the collider 2D to the sprite.
  • 3:57 - 3:59
    If the size and shape of the collider 2D
  • 3:59 - 4:03
    is undesirable then the shape can be edited by either
  • 4:03 - 4:05
    changing the values in the inspector
  • 4:07 - 4:11
    or changing the collider 2D itself in the scene view.
  • 4:11 - 4:14
    To edit a collider 2D in the scene view
  • 4:14 - 4:16
    hold down the shift key.
  • 4:17 - 4:19
    This will display handles on the 2D collider's
  • 4:19 - 4:21
    gizmo in the scene view.
  • 4:22 - 4:24
    These handles are drag-able.
  • 4:26 - 4:29
    In the case of the edge collider and the polygon collider
  • 4:29 - 4:31
    dragging an existing handle will move
  • 4:31 - 4:34
    the collider's vertex, and change the collider's shape
  • 4:34 - 4:37
    rather than resizing the collider.
  • 4:38 - 4:40
    By moving the cursor over an empty edge
  • 4:40 - 4:43
    on either the edge collider or the polygon collider
  • 4:43 - 4:46
    a new vertex can be created by clicking.
  • 4:47 - 4:49
    This is indicated by a new handle appearing
  • 4:49 - 4:52
    and the edge highlighting in green.
  • 4:58 - 5:01
    In the case of the edge collider and the polygon collider
  • 5:01 - 5:03
    holding the control key will allow a
  • 5:03 - 5:05
    vertex to the be deleted when clicked.
  • 5:06 - 5:08
    This is indicated by the handle
  • 5:08 - 5:10
    and the edge highlighting in red.
  • 5:16 - 5:19
    A game object does not need a rigidbodied
  • 5:19 - 5:21
    2D to use a collider 2D.
  • 5:22 - 5:25
    To participate in 2D collision and trigger events
  • 5:25 - 5:27
    however at least 1 of the game objects
  • 5:27 - 5:30
    involved must have a rigidbody 2D attached.
  • 5:31 - 5:33
    A common pattern for best performance
  • 5:33 - 5:36
    would be to attach collider 2D components
  • 5:36 - 5:38
    but not rigidbody components
  • 5:38 - 5:40
    to all of the static, or non-moving game objects
  • 5:40 - 5:43
    that need to interact with 2D physics.
  • 5:43 - 5:46
    And attach a collider 2D and a rigidbody 2D
  • 5:46 - 5:49
    to the dynamic, or moving, game object
  • 5:49 - 5:51
    that need to interact in the scene.
  • 5:54 - 5:56
    For more information on physics 2D
  • 5:56 - 5:58
    collider 2D, collisions and triggers
  • 5:58 - 6:01
    please see the information linked below.
Title:
Collider 2D - Official Unity Tutorial
Description:

more » « less
Video Language:
English
Duration:
06:09

Spanish subtitles

Revisions