class_physics2ddirectbodystate - vkbsb/godot GitHub Wiki

Physics2DDirectBodyState

####Inherits: Object ####Category: Core

Brief Description

Direct access object to a physics body in the Physics2DServer.

Member Functions

Description

Direct access object to a physics body in the Physics2DServer. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body.

Member Function Description

get_total_gravity

  • Vector2 get_total_gravity ( ) const

Return the total gravity vector being currently applied to this body.

get_total_density

  • float get_total_density ( ) const

Return the space density currently being applied to this body.

get_inverse_mass

  • float get_inverse_mass ( ) const

Return the inverse of the mass of the body.

get_inverse_inertia

  • float get_inverse_inertia ( ) const

Return the inverse of the inertia of the body.

set_linear_velocity

  • void set_linear_velocity ( Vector2 velocity )

Change the linear velocity of the body.

get_linear_velocity

  • Vector2 get_linear_velocity ( ) const

Return the current linear velocity of the body.

set_angular_velocity

  • void set_angular_velocity ( float velocity )

Change the angular velocity of the body.

get_angular_velocity

  • float get_angular_velocity ( ) const

Return the angular velocity of the body.

set_transform

  • void set_transform ( Matrix32 transform )

Change the transform matrix of the body.

get_transform

Return the transform matrix of the body.

set_sleep_state

  • void set_sleep_state ( bool enabled )

Set the sleeping state of the body, only affects character/rigid bodies.

is_sleeping

  • bool is_sleeping ( ) const

Return true if this body is currently sleeping (not active).

get_contact_count

  • int get_contact_count ( ) const

Return the amount of contacts this body has with other bodies. Note that by default this returns 0 unless bodies are configured to log contacts.

get_contact_local_pos

  • Vector2 get_contact_local_pos ( int contact_idx ) const

Return the local position (of this body) of the contact point.

get_contact_local_shape

  • int get_contact_local_shape ( int contact_idx ) const

Return the local shape index of the collision.

get_contact_collider

  • RID get_contact_collider ( int contact_idx ) const

Return the RID of the collider.

get_contact_collider_pos

  • Vector2 get_contact_collider_pos ( int contact_idx ) const

Return the contact position in the collider.

get_contact_collider_id

  • int get_contact_collider_id ( int contact_idx ) const

Return the object id of the collider.

get_contact_collider_object

  • Object get_contact_collider_object ( int contact_idx ) const

Return the collider object, this depends on how it was created (will return a scene node if such was used to create it).

get_contact_collider_shape

  • int get_contact_collider_shape ( int contact_idx ) const

Return the collider shape index.

get_contact_collider_velocity_at_pos

  • Vector2 get_contact_collider_velocity_at_pos ( int contact_idx ) const

Return the linear velocity vector at contact point of the collider.

get_step

  • float get_step ( ) const

Return the timestep (delta) used for the simulation.

integrate_forces

  • void integrate_forces ( )

Call the built-in force integration code.

get_space_state

Return the current state of space, useful for queries.