Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

CollisionShape2D

Eredita: Node2D < CanvasItem < Node < Object

Un nodo che fornisce uno Shape2D a un CollisionObject2D genitore.

Descrizione

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

Tutorial

Proprietà

Color

debug_color

Color(0, 0, 0, 0)

bool

disabled

false

bool

one_way_collision

false

Vector2

one_way_collision_direction

Vector2(0, 1)

float

one_way_collision_margin

1.0

Shape2D

shape


Descrizioni delle proprietà

Color debug_color = Color(0, 0, 0, 0) 🔗

  • void set_debug_color(value: Color)

  • Color get_debug_color()

Il colore di debug della forma di collisione che è visualizzato nell'editor, o nel progetto in esecuzione se Debug > Forme di collisione visibili.

Nota: Il valore predefinito è ProjectSettings.debug/shapes/collision/shape_color. Il valore Color(0, 0, 0, 1) documentato qui è un segnaposto e non il colore di debug predefinito effettivo.


bool disabled = false 🔗

  • void set_disabled(value: bool)

  • bool is_disabled()

Una forma di collisione disabilitata non ha alcun effetto nel mondo. Questa proprietà dovrebbe essere modificata con Object.set_deferred().


bool one_way_collision = false 🔗

  • void set_one_way_collision(value: bool)

  • bool is_one_way_collision_enabled()

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.

Note: The one way collision direction can be configured by setting one_way_collision_direction.


Vector2 one_way_collision_direction = Vector2(0, 1) 🔗

  • void set_one_way_collision_direction(value: Vector2)

  • Vector2 get_one_way_collision_direction()

The direction used for one-way collision.


float one_way_collision_margin = 1.0 🔗

  • void set_one_way_collision_margin(value: float)

  • float get_one_way_collision_margin()

Il margine utilizzato per la collisione a senso unico (in pixel). Valori più alti renderanno la forma più spessa e funzioneranno meglio per i collisori che entrano nella forma ad alta velocità.


Shape2D shape 🔗

La forma reale appartenente a questa forma di collisione.