CollisionObject2D

Inherits: Node2D < CanvasItem < Node < Object

Inherited By: Area2D, PhysicsBody2D

Category: Core

Brief Description

Base node for 2D collisionables.

Member Functions

void _input_event ( Object viewport, InputEvent event, int shape_idx ) virtual
void add_shape ( Shape2D shape, Matrix32 transform=((1, 0), (0, 1), (0, 0)) )
void clear_shapes ( )
RID get_rid ( ) const
Shape2D get_shape ( int shape_idx ) const
int get_shape_count ( ) const
Matrix32 get_shape_transform ( int shape_idx ) const
bool is_pickable ( ) const
bool is_shape_set_as_trigger ( int shape_idx ) const
void remove_shape ( int shape_idx )
void set_pickable ( bool enabled )
void set_shape ( int shape_idx, Shape shape )
void set_shape_as_trigger ( int shape_idx, bool enable )
void set_shape_transform ( int shape_idx, Matrix32 transform )

Signals

  • input_event ( Object viewport, InputEvent event, int shape_idx )
  • mouse_enter ( )
  • mouse_exit ( )

Description

CollisionObject2D is the base class for 2D physics collisionables. They can hold any number of 2D collision shapes. Usually, they are edited by placing CollisionShape2D and/or CollisionPolygon2D nodes as children. Such nodes are for reference and not present outside the editor, so code should use the regular shape API.

Member Function Description

This method can be used to override normal input processing. The first parameter is the viewport where the event took place. The second holds the input event received, and the third the shape of this object where it happened.

  • void add_shape ( Shape2D shape, Matrix32 transform=((1, 0), (0, 1), (0, 0)) )

Add a Shape2D to the collision body, with a given custom transform.

  • void clear_shapes ( )

Remove all shapes.

  • RID get_rid ( ) const

Return the RID of this object.

Return the shape in the given index.

  • int get_shape_count ( ) const

Return the amount of shapes in the collision body. Because a CollisionPolygon2D can generate more than one Shape2D, the amount returned does not have to match the sum of CollisionShape2D and CollisionPolygon2D.

Return the shape transform in the given index.

  • bool is_pickable ( ) const

Return whether this object is pickable.

  • bool is_shape_set_as_trigger ( int shape_idx ) const

Return whether a shape is a trigger. A trigger shape detects collisions, but is otherwise unaffected by physics (i.e. colliding objects will not get blocked).

  • void remove_shape ( int shape_idx )

Remove the shape in the given index.

  • void set_pickable ( bool enabled )

Set whether this object is pickable. A pickable object can detect the mouse pointer enter/leave it and, if the mouse is inside it, report input events.

  • void set_shape ( int shape_idx, Shape shape )

Change a shape in the collision body.

  • void set_shape_as_trigger ( int shape_idx, bool enable )

Set whether a shape is a trigger. A trigger shape detects collisions, but is otherwise unaffected by physics (i.e. colliding objects will not get blocked).

  • void set_shape_transform ( int shape_idx, Matrix32 transform )

Change the shape transform in the collision body.