StaticBody2D

Inherits: PhysicsBody2D < CollisionObject2D < Node2D < CanvasItem < Node < Object

Category: Core

Brief Description

Static body for 2D Physics.

Description

Static body for 2D Physics. A static body is a simple body that is not intended to move. They don’t consume any CPU resources in contrast to a RigidBody2D so they are great for scenario collision.

A static body can also be animated by using simulated motion mode. This is useful for implementing functionalities such as moving platforms. When this mode is active the body can be animated and automatically computes linear and angular velocity to apply in that frame and to influence other bodies.

Alternatively, a constant linear or angular velocity can be set for the static body, so even if it doesn’t move, it affects other bodies as if it was moving (this is useful for simulating conveyor belts or conveyor wheels).

Member Function Description

  • float get_bounce ( ) const

Return the body bounciness.

  • float get_constant_angular_velocity ( ) const

Return the constant angular velocity for the body.

  • Vector2 get_constant_linear_velocity ( ) const

Return the constant linear velocity for the body.

  • float get_friction ( ) const

Return the body friction.

  • void set_bounce ( float bounce )

Set the body bounciness, from 0 (not bouncy) to 1 (bouncy).

  • void set_constant_angular_velocity ( float vel )

Set a constant angular velocity for the body. This does not rotate the body, but affects other bodies touching it, as if it was rotating.

  • void set_constant_linear_velocity ( Vector2 vel )

Set a constant linear velocity for the body. This does not move the body, but affects other bodies touching it, as if it was moving.

  • void set_friction ( float friction )

Set the body friction, from 0 (frictionless) to 1 (full friction).