CollisionObject3D

Inherits: Node3D < Node < Object

Inherited By: Area3D, PhysicsBody3D

Base node for collision objects.

Description

CollisionObject3D is the base class for physics objects. It can hold any number of collision Shape3Ds. Each shape must be assigned to a shape owner. The CollisionObject3D 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.

Methods

void

_input_event ( Camera3D camera, InputEvent event, Vector3 position, Vector3 normal, int shape_idx ) virtual

int

create_shape_owner ( Object owner )

bool

get_collision_layer_value ( int layer_number ) const

bool

get_collision_mask_value ( int layer_number ) const

RID

get_rid ( ) const

Array

get_shape_owners ( )

bool

is_shape_owner_disabled ( int owner_id ) const

void

remove_shape_owner ( int owner_id )

void

set_collision_layer_value ( int layer_number, bool value )

void

set_collision_mask_value ( int layer_number, bool value )

int

shape_find_owner ( int shape_index ) const

void

shape_owner_add_shape ( int owner_id, Shape3D shape )

void

shape_owner_clear_shapes ( int owner_id )

Object

shape_owner_get_owner ( int owner_id ) const

Shape3D

shape_owner_get_shape ( int owner_id, int shape_id ) const

int

shape_owner_get_shape_count ( int owner_id ) const

int

shape_owner_get_shape_index ( int owner_id, int shape_id ) const

Transform3D

shape_owner_get_transform ( int owner_id ) const

void

shape_owner_remove_shape ( int owner_id, int shape_id )

void

shape_owner_set_disabled ( int owner_id, bool disabled )

void

shape_owner_set_transform ( int owner_id, Transform3D transform )

Signals

Emitted when the object receives an unhandled InputEvent. position is the location in world space of the mouse pointer on the surface of the shape with index shape_idx and normal is the normal vector of the surface at that point.


  • mouse_entered ( )

Emitted when the mouse pointer enters any of this object's shapes.


  • mouse_exited ( )

Emitted when the mouse pointer exits all this object's shapes.

Enumerations

enum DisableMode:

Automatically re-added to the physics simulation when the Node is processed again.

Automatically set PhysicsBody3D back to its original mode when the Node is processed again.

Property Descriptions

  • int collision_layer

Default

1

Setter

set_collision_layer(value)

Getter

get_collision_layer()

The physics layers this CollisionObject3D is in. Collision objects can exist in one or more of 32 different layers. See also collision_mask.

Note: Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See Collision layers and masks in the documentation for more information.


  • int collision_mask

Default

1

Setter

set_collision_mask(value)

Getter

get_collision_mask()

The physics layers this CollisionObject3D scans. Collision objects can scan one or more of 32 different layers. See also collision_layer.

Note: Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See Collision layers and masks in the documentation for more information.


Default

0

Setter

set_disable_mode(value)

Getter

get_disable_mode()

Defines the behavior in physics when Node.process_mode is set to Node.PROCESS_MODE_DISABLED. See DisableMode for more details about the different modes.


  • bool input_capture_on_drag

Default

false

Setter

set_capture_input_on_drag(value)

Getter

get_capture_input_on_drag()

If true, the CollisionObject3D will continue to receive input events as the mouse is dragged across its shapes.


  • bool input_ray_pickable

Default

true

Setter

set_ray_pickable(value)

Getter

is_ray_pickable()

If true, the CollisionObject3D's shapes will respond to RayCast3Ds.

Method Descriptions

Receives unhandled InputEvents. position is the location in world space of the mouse pointer on the surface of the shape with index shape_idx and normal is the normal vector of the surface at that point. Connect to the input_event signal to easily pick up these events.


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


  • bool get_collision_layer_value ( int layer_number ) const

Returns whether or not the specified layer of the collision_layer is enabled, given a layer_number between 1 and 32.


  • bool get_collision_mask_value ( int layer_number ) const

Returns whether or not the specified layer of the collision_mask is enabled, given a layer_number between 1 and 32.


  • RID get_rid ( ) const

Returns the object's RID.


  • Array get_shape_owners ( )

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


  • bool is_shape_owner_disabled ( int owner_id ) const

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


  • void remove_shape_owner ( int owner_id )

Removes the given shape owner.


  • void set_collision_layer_value ( int layer_number, bool value )

Based on value, enables or disables the specified layer in the collision_layer, given a layer_number between 1 and 32.


  • void set_collision_mask_value ( int layer_number, bool value )

Based on value, enables or disables the specified layer in the collision_mask, given a layer_number between 1 and 32.


  • int shape_find_owner ( int shape_index ) const

Returns the owner_id of the given shape.


  • void shape_owner_add_shape ( int owner_id, Shape3D shape )

Adds a Shape3D to the shape owner.


  • void shape_owner_clear_shapes ( int owner_id )

Removes all shapes from the shape owner.


  • Object shape_owner_get_owner ( int owner_id ) const

Returns the parent object of the given shape owner.


  • Shape3D shape_owner_get_shape ( int owner_id, int shape_id ) const

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


  • int shape_owner_get_shape_count ( int owner_id ) const

Returns the number of shapes the given shape owner contains.


  • int shape_owner_get_shape_index ( int owner_id, int shape_id ) const

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


Returns the shape owner's Transform3D.


  • void shape_owner_remove_shape ( int owner_id, int shape_id )

Removes a shape from the given shape owner.


  • void shape_owner_set_disabled ( int owner_id, bool disabled )

If true, disables the given shape owner.


  • void shape_owner_set_transform ( int owner_id, Transform3D transform )

Sets the Transform3D of the given shape owner.