Search Unity

Collider Question

Discussion in 'Scripting' started by marty, Jul 1, 2005.

  1. marty

    marty

    Joined:
    Apr 27, 2005
    Posts:
    1,170
    When I transform and object with a collider attached to it, are all of my transforms passed on from the mesh to its collider (as if they were parent and child)?
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Yes.

    The long answer is: we use a component system, where we don't think of the transform being attached to the mesh or the collider.

    The game object contains a transform.

    The game object also contains a mesh. When the mesh renders itself it asks the transform in the same game object for the position.

    The same goes for the collider.

    So if you change a transform all components attached to the game object will know about it. If the transform has children, all children of the transform including all colliders or meshes will know about the change too.
     
  3. marty

    marty

    Joined:
    Apr 27, 2005
    Posts:
    1,170
    So, when I look over at the Unity Inspector with an object selected, the top-most roll-out (the one with the little box icon) is the game object.

    And, everything below that roll-out is other objects instanced into that game object. Some are bundles of properties, while others include methods (i.e. scripts).

    Is that sort of how it works?
     
  4. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Yes that is sort of how it works.

    Most components are a bit more than bundles of properties of course because they contain a lot of functionality. Eg. A rigidbody contains properties visible to the user but behind the back it talks to other components eg. colliders and every frame updates itself and modifies the position and rotation of the transform.