CollisionObject2D

    Inherited By: , PhysicsBody2D

    Category: Core

    Base node for 2D collision objects.

    Properties

    Signals

    • input_event ( viewport, InputEvent event, shape_idx )

    Emitted when an input event occurs. Requires input_pickable to be and at least one collision_layer bit to be set. See for details.


    • mouse_entered ( )

    Emitted when the mouse pointer enters any of this object’s shapes. Requires input_pickable to be true and at least one collision_layer bit to be set.


    • mouse_exited ( )

    Emitted when the mouse pointer exits all this object’s shapes. Requires to be true and at least one collision_layer bit to be set.

    CollisionObject2D is the base class for 2D physics objects. It can hold any number of 2D collision Shape2Ds. Each shape must be assigned to a shape owner. The CollisionObject2D can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the shape_owner_* methods.

    Property Descriptions

    If true, this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one bit to be set.

    • void _input_event ( viewport, InputEvent event, shape_idx ) virtual

    • int create_shape_owner ( owner )

    Creates a new shape owner for the given object. Returns owner_id of the new owner for future reference.


    • RID get_rid ( ) const

    Returns the object’s .


    • float get_shape_owner_one_way_collision_margin ( owner_id ) const

    • Array get_shape_owners ( )

    Returns an of owner_id identifiers. You can use these ids in other methods that take owner_id as an argument.


    • bool is_shape_owner_disabled ( owner_id ) const

    If true, the shape owner and its shapes are disabled.


    • bool is_shape_owner_one_way_collision_enabled ( owner_id ) const

    Returns if collisions for the shape owner originating from this CollisionObject2D will not be reported to collided with CollisionObject2Ds.


    • void remove_shape_owner ( int owner_id )

    Removes the given shape owner.


    • shape_find_owner ( int shape_index ) const

    Returns the owner_id of the given shape.


    • void shape_owner_add_shape ( owner_id, Shape2D shape )

    Adds a to the shape owner.



    • Object shape_owner_get_owner ( owner_id ) const

    Returns the parent object of the given shape owner.


    • Shape2D shape_owner_get_shape ( owner_id, int shape_id ) const

    Returns the with the given id from the given shape owner.


    • int shape_owner_get_shape_count ( owner_id ) const

    Returns the number of shapes the given shape owner contains.


    • int shape_owner_get_shape_index ( owner_id, int shape_id ) const

    Returns the child index of the with the given id from the given shape owner.


    • Transform2D shape_owner_get_transform ( owner_id ) const

    Returns the shape owner’s Transform2D.


    • void shape_owner_remove_shape ( owner_id, int shape_id )

    Removes a shape from the given shape owner.


    • void shape_owner_set_disabled ( owner_id, bool disabled )

    If true, disables the given shape owner.


    • void shape_owner_set_one_way_collision ( owner_id, bool enable )

    If enable is true, collisions for the shape owner originating from this CollisionObject2D will not be reported to collided with s.


    • void shape_owner_set_one_way_collision_margin ( owner_id, float margin )

    • void shape_owner_set_transform ( owner_id, Transform2D transform )