Base node for 2D collisionables.
|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 )|
This signal triggers when an input event fires over a shape. 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.
- mouse_enter ( )
This event fires only once when the mouse pointer enters any shape of this object.
- mouse_exit ( )
This event fires only once when the mouse pointer exits all shapes of this object.
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.
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.
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.
Change a shape in the collision body.
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).
Change the shape transform in the collision body.