Table of Contents

Class CollisionShape2D

A node that provides a Shape2D to a CollisionObject2D parent.

Inheritance
CollisionShape2D

Remarks

A node that provides a Shape2D to a CollisionObject2D parent and allows to edit it. This can give a detection shape to an Area2D or turn a PhysicsBody2D into a solid object.

See Also

Properties

debug_color

The collision shape color that is displayed in the editor, or in the running project if Debug > Visible Collision Shapes is checked at the top of the editor.

Note: The default value is debug/shapes/collision/shape_color. The Color(0, 0, 0, 0) value documented here is a placeholder, and not the actual default debug color.

var debug_color : Color = Color(0, 0, 0, 0)

Property Value

Color

Remarks

  • void set_debug_color(Color value)
  • Color get_debug_color

disabled

A disabled collision shape has no effect in the world. This property should be changed with Object.set_deferred.

var disabled : bool = false

Property Value

bool

Remarks

  • void set_disabled(bool value)
  • bool is_disabled

one_way_collision

Sets whether this collision shape should only detect collision on one side (top or bottom).

Note: This property has no effect if this CollisionShape2D is a child of an Area2D node.

var one_way_collision : bool = false

Property Value

bool

Remarks

  • void set_one_way_collision(bool value)
  • bool is_one_way_collision_enabled

one_way_collision_margin

The margin used for one-way collision (in pixels). Higher values will make the shape thicker, and work better for colliders that enter the shape at a high velocity.

var one_way_collision_margin : float = 1.0

Property Value

float

Remarks

  • void set_one_way_collision_margin(float value)
  • float get_one_way_collision_margin

shape

The actual shape owned by this collision shape.

var shape : Shape2D

Property Value

Shape2D

Remarks