Table of Contents

Class CollisionObject3D

Namespace
Godot
Assembly
GodotSharp.dll

Abstract base class for 3D physics objects. CollisionObject3D can hold any number of Shape3Ds for collision. Each shape must be assigned to a shape owner. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the shape_owner_* methods.

Warning: With a non-uniform scale, this node will likely not behave as expected. It is advised to keep its scale the same on all axes and adjust its collision shape(s) instead.

public class CollisionObject3D : Node3D, IDisposable
Inheritance
CollisionObject3D
Implements
Derived
Inherited Members

Properties

CollisionLayer

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

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.

public uint CollisionLayer { get; set; }

Property Value

uint

CollisionMask

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

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.

public uint CollisionMask { get; set; }

Property Value

uint

CollisionPriority

The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.

public float CollisionPriority { get; set; }

Property Value

float

DisableMode

Defines the behavior in physics when ProcessMode is set to Disabled. See CollisionObject3D.DisableModeEnum for more details about the different modes.

public CollisionObject3D.DisableModeEnum DisableMode { get; set; }

Property Value

CollisionObject3D.DisableModeEnum

InputCaptureOnDrag

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

public bool InputCaptureOnDrag { get; set; }

Property Value

bool

InputRayPickable

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 CollisionLayer bit to be set.

public bool InputRayPickable { get; set; }

Property Value

bool

Methods

CreateShapeOwner(GodotObject)

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

public uint CreateShapeOwner(GodotObject owner)

Parameters

owner GodotObject

Returns

uint

GetCollisionLayerValue(int)

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

public bool GetCollisionLayerValue(int layerNumber)

Parameters

layerNumber int

Returns

bool

GetCollisionMaskValue(int)

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

public bool GetCollisionMaskValue(int layerNumber)

Parameters

layerNumber int

Returns

bool

GetRid()

Returns the object's Rid.

public Rid GetRid()

Returns

Rid

GetShapeOwners()

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

public int[] GetShapeOwners()

Returns

int[]

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

IsShapeOwnerDisabled(uint)

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

public bool IsShapeOwnerDisabled(uint ownerId)

Parameters

ownerId uint

Returns

bool

RemoveShapeOwner(uint)

Removes the given shape owner.

public void RemoveShapeOwner(uint ownerId)

Parameters

ownerId uint

SetCollisionLayerValue(int, bool)

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

public void SetCollisionLayerValue(int layerNumber, bool value)

Parameters

layerNumber int
value bool

SetCollisionMaskValue(int, bool)

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

public void SetCollisionMaskValue(int layerNumber, bool value)

Parameters

layerNumber int
value bool

ShapeFindOwner(int)

Returns the owner_id of the given shape.

public uint ShapeFindOwner(int shapeIndex)

Parameters

shapeIndex int

Returns

uint

ShapeOwnerAddShape(uint, Shape3D)

Adds a Shape3D to the shape owner.

public void ShapeOwnerAddShape(uint ownerId, Shape3D shape)

Parameters

ownerId uint
shape Shape3D

ShapeOwnerClearShapes(uint)

Removes all shapes from the shape owner.

public void ShapeOwnerClearShapes(uint ownerId)

Parameters

ownerId uint

ShapeOwnerGetOwner(uint)

Returns the parent object of the given shape owner.

public GodotObject ShapeOwnerGetOwner(uint ownerId)

Parameters

ownerId uint

Returns

GodotObject

ShapeOwnerGetShape(uint, int)

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

public Shape3D ShapeOwnerGetShape(uint ownerId, int shapeId)

Parameters

ownerId uint
shapeId int

Returns

Shape3D

ShapeOwnerGetShapeCount(uint)

Returns the number of shapes the given shape owner contains.

public int ShapeOwnerGetShapeCount(uint ownerId)

Parameters

ownerId uint

Returns

int

ShapeOwnerGetShapeIndex(uint, int)

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

public int ShapeOwnerGetShapeIndex(uint ownerId, int shapeId)

Parameters

ownerId uint
shapeId int

Returns

int

ShapeOwnerGetTransform(uint)

Returns the shape owner's Transform3D.

public Transform3D ShapeOwnerGetTransform(uint ownerId)

Parameters

ownerId uint

Returns

Transform3D

ShapeOwnerRemoveShape(uint, int)

Removes a shape from the given shape owner.

public void ShapeOwnerRemoveShape(uint ownerId, int shapeId)

Parameters

ownerId uint
shapeId int

ShapeOwnerSetDisabled(uint, bool)

If true, disables the given shape owner.

public void ShapeOwnerSetDisabled(uint ownerId, bool disabled)

Parameters

ownerId uint
disabled bool

ShapeOwnerSetTransform(uint, Transform3D)

Sets the Transform3D of the given shape owner.

public void ShapeOwnerSetTransform(uint ownerId, Transform3D transform)

Parameters

ownerId uint
transform Transform3D

_InputEvent(Camera3D, InputEvent, Vector3, Vector3, int)

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

Note: _InputEvent(Camera3D, InputEvent, Vector3, Vector3, int) requires InputRayPickable to be true and at least one CollisionLayer bit to be set.

public virtual void _InputEvent(Camera3D camera, InputEvent @event, Vector3 position, Vector3 normal, int shapeIdx)

Parameters

camera Camera3D
event InputEvent
position Vector3
normal Vector3
shapeIdx int

_MouseEnter()

Called when the mouse pointer enters any of this object's shapes. Requires InputRayPickable to be true and at least one CollisionLayer bit to be set. Note that moving between different shapes within a single CollisionObject3D won't cause this function to be called.

public virtual void _MouseEnter()

_MouseExit()

Called when the mouse pointer exits all this object's shapes. Requires InputRayPickable to be true and at least one CollisionLayer bit to be set. Note that moving between different shapes within a single CollisionObject3D won't cause this function to be called.

public virtual void _MouseExit()

Events

InputEvent

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 shapeIdx and normal is the normal vector of the surface at that point.

public event CollisionObject3D.InputEventEventHandler InputEvent

Event Type

CollisionObject3D.InputEventEventHandler

MouseEntered

Emitted when the mouse pointer enters any of this object's shapes. Requires InputRayPickable to be true and at least one CollisionLayer bit to be set.

Note: Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the CollisionObject3D's area is small. This signal may also not be emitted if another CollisionObject3D is overlapping the CollisionObject3D in question.

public event Action MouseEntered

Event Type

Action

MouseExited

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

Note: Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the CollisionObject3D's area is small. This signal may also not be emitted if another CollisionObject3D is overlapping the CollisionObject3D in question.

public event Action MouseExited

Event Type

Action