Rigidbody2D

class in UnityEngine

/

Hereda de:Component

Cambiar al Manual

Descripción

Componente de física de un Rigidbody para sprites 2D.

The Rigidbody2D class essentially provides the same functionality in 2D that the Rigidbody class provides in 3D. Adding a Rigidbody2D component to a sprite puts it under the control of the physics engine. By itself, this means that the sprite will be affected by gravity and can be controlled from scripts using forces. By adding the appropriate collider component, the sprite will also respond to collisions with other sprites. This behaviour comes entirely from Unity's physics system; very little code is required to get impressive and authentic physical behaviour and allows for "emergent" gameplay that was not explicitly coded into the game.

See Also: Clase Rigidbody, Clase SpriteRenderer, Clase Collider2D, Clase Joint2D.

Variables

angularDragCoeficiente de rozamiento angular.
angularVelocityVelocidad angular en grados por segundo.
attachedColliderCountReturns the number of Collider2D attached to this Rigidbody2D.
bodyTypeLa posición del rigidbody.
centerOfMassEl centro de masa del rigidBody en el espacio local.
collisionDetectionModeEl método usado por el motor de física para verificar si dos objetos han colisionado.
constraintsControls which degrees of freedom are allowed for the simulation of this Rigidbody2D.
dragCoeficiente de arrastre.
freezeRotationControla si la física cambiará la rotación del objeto.
gravityScaleEl grado en que este objeto está afectado por la gravedad.
inertiaThe Rigidbody's resistance to changes in angular velocity (rotation).
interpolationInterpolación física usada entre actualizaciones.
isKinematic¿El rigidbody debe ser sacado del control de la física?
massMass of the Rigidbody.
positionLa posición del rigidbody.
rotationLa rotación del rigidbody.
sharedMaterialThe PhysicsMaterial2D that is applied to all Collider2D attached to this Rigidbody2D.
simulatedIndica si el rigidbody debiera ser simulado o no por el sistema de física.
sleepModeEl estado de sueño en que el rigidbody se encontrará inicialmente.
useAutoMassShould the total rigid-body mass be automatically calculated from the [[Collider2D.density]] of attached colliders?
useFullKinematicContactsShould kinematic/kinematic and kinematic/static collisions be allowed?
velocityLinear velocity of the Rigidbody in units per second.
worldCenterOfMassObtiene el centro de masa del rigidBody en el espacio global.

Funciones Públicas

AddForceAplica una fuerza al rigidbody.
AddForceAtPositionAplica una fuerza en una posición en el espacio.
AddRelativeForceAñade una fuerza al rigidbody2D que es relativa a su sistema de coordenadas.
AddTorqueAplica un torque hacia el centro de masa del rigidbody.
CastAll the Collider2D shapes attached to the Rigidbody2D are cast into the Scene starting at each Collider position ignoring the Colliders attached to the same Rigidbody2D.
ClosestPointReturns a point on the perimeter of all enabled Colliders attached to this Rigidbody that is closest to the specified position.
DistanceCalculates the minimum distance of this collider against all Collider2D attached to this Rigidbody2D.
GetAttachedCollidersReturns all Collider2D that are attached to this Rigidbody2D.
GetContactsRetrieves all contact points for all of the Collider(s) attached to this Rigidbody.
GetPointObtener un punto del espacio local, dado el punto point en el espacio global del rigidBody.
GetPointVelocityLa velocidad del rigidbody en el punto Point en el espacio global.
GetRelativePointObtiene un punto del espacio global, teniendo en cuenta el punto relativePoint en el espacio local del rigidBody.
GetRelativePointVelocityLa velocidad del rigidbody en el punto Point en espacio local.
GetRelativeVectorObtiene un vector del espacio global, dado el vector relativeVector en el espacio local del rigidBody.
GetVectorObtiene un vector del espacio local, dado el vector vector en el espacio global del rigidBody.
IsAwake¿El rigidbody está "despierto"?
IsSleeping¿El rigidbody está "durmiendo"?
IsTouchingChecks whether the collider is touching any of the collider(s) attached to this rigidbody or not.
IsTouchingLayersChecks whether any of the collider(s) attached to this rigidbody are touching any colliders on the specified layerMask or not.
MovePositionMueve el rigidbody a la posición position.
MoveRotationRotates the Rigidbody to angle (given in degrees).
OverlapColliderGet a list of all Colliders that overlap all Colliders attached to this Rigidbody2D.
OverlapPointCheck if any of the Rigidbody2D colliders overlap a point in space.
SetRotationSets the rotation of the Rigidbody2D to angle (given in degrees).
SleepHace que el rigidbody "duerma".
WakeUpDeshabilita el estado de "dormir" de un rigidbody.

Miembros heredados

Variables

gameObjectEl game object que tiene este componente adjunto. Un componente siempre está adjunto a un game object.
tagEl tag de este game object.
transformThe Transform attached to this GameObject.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameEl nombre del objeto.

Funciones Públicas

BroadcastMessageLlama al método denominado methodName de todos los MonoBehaviour en este game objecto en cualquiera de sus hijos.
CompareTag¿Este game object está etiquetado con tag?
GetComponentReturns the component of Type type if the GameObject has one attached, null if it doesn't. Will also return disabled components.
GetComponentInChildrenRetorna el componente de tipo type en el GameObject o cualquiera de sus hijos utilizando depth first search (busqueda de profundidad).
GetComponentInParentRetorna el componente de tipo type en el GameObject o cualquiera de sus padres.
GetComponentsRetorna todos los componentes de tipo type en el GameObject.
GetComponentsInChildrenRetorna todos los componentes de tipo type en el GameObject o cualquiera de sus hijo.
GetComponentsInParentRetorna todos los componentes de tipo type en el GameObject o cualquiera de sus padres.
SendMessageLlama al método denominado methodName en cada MonoBehaviour de este game object.
SendMessageUpwardsLlama al método denominado methodName en todos los MonoBehaviour de este juego y en todos los ancestros del behaviour.
TryGetComponentGets the component of the specified type, if it exists.
GetInstanceIDDevuelve el id de la instancia del objeto.
ToStringReturns the name of the object.

Funciones Estáticas

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindObjectOfTypeDevuelve el primer objeto activo cargado de tipo type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClona el objeto original y devuelve el clon.

Operadores

bool¿Existe el objeto?
operator !=Compare si dos objetos se refieren a un objeto diferente.
operator ==Compara dos referencias de objeto para ver si se refieren al mismo objeto.