PhysicsRigidbodyComponent

Entity is controlled by the physics engine. You can set values that affect physics calculations.

# Properties

[{"index":"float AngularDamping (Sync)","0":"Sets the coefficient of resistance to changes in angular velocity. The larger the value is, the more force is required to change the angular velocity. Must set a value equal to or greater than 0."}]

[{"index":"BodyType BodyType (Sync)","0":"Set the rigid body type."}]

[{"index":"PhysicsCollisionDetectionMode CollisionDetectionMode (Sync)","0":"Sets the detection method for physics collision."}]

[{"index":"boolean FixedRotation (Sync)","0":"If true, the object does not rotate due to physics interactions."}]

[{"index":"float Friction (Sync)","0":"Determines the coefficient of friction. The smaller the value is, the better it slides. Must set a value equal to or greater than 0."}]

[{"index":"float GravityScale (Sync)","0":"Sets how much the effect of gravity is. If the value is 0, gravity has no effect and if it is 1, gravity has a direct effect. The larger the value is, the more effect gravity has."}]

[{"index":"float LinearDamping (Sync)","0":"Sets the coefficient of resistance for the change of the linear velocity. The larger the value is, the more force is required to change the linear velocity."}]

[{"index":"float Mass (Sync)","0":"Sets the mass value. Calculate the density value using the values of the area and mass of the Collider."}]

[{"index":"float Restitution (Sync)","0":"Determines how much bounce occurs after a collision. 0 is close to perfectly inelastic collision, 1 is close to perfectly elastic collision."}]

[{"index":"PhysicsSleepingMode SleepingMode (Sync)","0":"Sets the sleep state of the collision."}]

[{"index":"boolean UseDensity (Sync)","0":"If true, the mass value is calculated using the density and collider values of PhysicsRigidbodyComponent instead of the mass value.If multiple PhysicsRigidbodyComponents are attached to one PhysicsRigidbodyComponent, the value obtained by multiplying the density of each PhysicsRigidbodyComponent by the collider size is used as the mass value."}]

##### inherited from Component:

[{"index":"boolean Enable (Sync)","0":"Checks whether Component is activated or not."}]

[{"index":"boolean EnableInHierarchy (ReadOnly) (HideFromInspector)","0":"Displays whether this Component is Enable in the hierarchy. If Entity Enable is false regardless of Component Enable, returns false."}]

[{"index":"Entity Entity (ReadOnly)","0":"The Entity that owns this component."}]

# Methods

[{"index":"void ApplyAngularImpulse(float impulse)","0":"Applies each impulse to the rigid body counterclockwise (CCW)."}]

[{"index":"void ApplyForce(Vector2 force)","0":"Apply a force in a specific direction to the center of gravity of a rigid body."}]

[{"index":"void ApplyForce(Vector2 force, Vector2 worldPoint)","0":"Apply a force to a rigid body in a specific direction at a specific location in the world."}]

[{"index":"void ApplyLinearImpulse(Vector2 impulse)","0":"Applies a linear impulse in a specific direction to the center of gravity of a rigid body."}]

[{"index":"void ApplyLinearImpulse(Vector2 impulse, Vector2 worldPoint)","0":"Applies a linear impulse to a rigid body in a specific direction at a specific location in the world."}]

[{"index":"void ApplyTorque(float force)","0":"Applies a rotational force to the rigid body in a counterclockwise (CCW) direction."}]

[{"index":"void ClearPhysicsOwnership() (Server)","0":"Automatically grants physics ownership. A Contact Event occurs only on the Server."}]

[{"index":"float GetAngularVelocity()","0":"Returns the angular velocity of a rigid body."}]

[{"index":"float GetDensity()","0":"Returns the density of a rigid body."}]

[{"index":"Vector2 GetLinearVelocity()","0":"Returns the linear velocity of a rigid body."}]

[{"index":"Vector2 GetLinearVelocityAtPoint(Vector2 worldPoint)","0":"Returns the linear velocity of a rigid body at a specific location in the world."}]

[{"index":"Vector2 GetPosition()","0":"Returns the location of a rigid body."}]

[{"index":"float GetRotation()","0":"Returns the angle of rotation of a rigid body."}]

[{"index":"void SetAngularVelocity(float velocity)","0":"Sets the angular velocity of a rigid body."}]

[{"index":"void SetClientAsPhysicsOwner(string userId) (ServerOnly)","0":"Grants physics ownership to a specific user. A Contact Event occurs on the corresponding Client and the Server."}]

[{"index":"void SetLinearVelocity(Vector2 velocity)","0":"Sets the linear velocity of a rigid body. Not affected by mass."}]

[{"index":"void SetLinearVelocityX(float velocityX)","0":"Sets the linear velocity X value of the rigid body. It is not affected by mass."}]

[{"index":"void SetLinearVelocityY(float velocityY)","0":"Sets the linear velocity Y value of the rigid body. It is not affected by mass."}]

[{"index":"void SetPosition(Vector2 position)","0":"Sets the location of the rigid body."}]

[{"index":"void SetRotation(float angle)","0":"Returns the angle of rotation of a rigid body."}]

[{"index":"void SetServerAsPhysicsOwner() (Server)","0":"Grants physics ownership to the server. A Contact Event occurs on the Server."}]

[{"index":"void Sleep()","0":"Puts the rigid body to sleep."}]

[{"index":"void Wake()","0":"Change a rigid body to an awake state."}]

##### inherited from Component:

[{"index":"boolean IsClient()","0":"Returns whether the current execution environment is a client or not."}]

[{"index":"boolean IsServer()","0":"Returns whether the current execution environment is a server or not."}]

# Examples

#### ApplyLinearImpulse
    
    
    @Component
    script ContactImpulseBooster extends Component
        @EventSender("Self")
        handler HandlePhysicsContactBeginEvent(PhysicsContactBeginEvent event)
        --------------- Native Event Sender Info ----------------
        -- Sender: PhysicsColliderComponent
        -- Space: Server, Client
        ---------------------------------------------------------
    
        -- Parameters
        local ContactedBodyEntity = event.ContactedBodyEntity
        ---------------------------------------------------------
        ContactedBodyEntity.PhysicsRigidbodyComponent:ApplyLinearImpulse(Vector2(0, 5))
        end
    end
    

#### GravityScale
    
    
    @Component
    script CollisionGravityScaler extends Component
        @EventSender("Self")
        handler HandlePhysicsContactBeginEvent(PhysicsContactBeginEvent event)
        --------------- Native Event Sender Info ----------------
        -- Sender: PhysicsColliderComponent
        -- Space: Server, Client
        ---------------------------------------------------------
    
        -- Parameters
        local ContactedBodyEntity = event.ContactedBodyEntity
        ---------------------------------------------------------
        ContactedBodyEntity.PhysicsRigidbodyComponent.GravityScale = 0.2
        end
    end
    

# SeeAlso

  * PhysicsContactBeginEvent
  * [Applying Physics to Entities ](/docs?postId=761)
  * [Using Physics](/docs?postId=757)
  * [Using Various Physics Joints](/docs?postId=760)