Skip to content

CollisionComponent

CollisionComponent

collision_layer property writable

collision_layer: int

CollisionLayer bit flags describing what this object is. Combined with other objects' collision_mask to decide whether they collide.

collision_mask property writable

collision_mask: int

CollisionMask bit flags describing which layers this object collides with

enable property writable

enable: bool

Whether this component is active

is_static property writable

is_static: bool

Whether this object is treated as immovable for collision resolution (other bodies collide against it, but it is never pushed)

owner property

owner: Object

The Object that owns this component

resolution_shape_id property writable

resolution_shape_id: int

Id of the shape used for physical collision resolution. -1 means None: shapes stay collidable for detection, but nothing is physically resolved.

shape property writable

shape: PolygonShape | RectangleShape | CircleShape

The resolution shape used for physical collision response. Equivalent to calling set_shape() with no shape_id.

sync_with_render_component property writable

sync_with_render_component: bool

Whether the resolution shape (or the first shape if none is set as resolution) automatically mirrors this object's RenderComponent shape. When True, calling set_shape() on that shape will be overridden on the next sync.

add_child

add_child(obj: Object) -> Object

Add obj as a child of this component's owning Object

add_collision_callback

add_collision_callback(callback: Callable) -> int

Fires every physics substep while two shapes are overlapping. Returns an id usable with remove_collision_callback().

add_collision_enter_callback

add_collision_enter_callback(callback: Callable) -> int

Fires once on the frame a collision first begins.

add_collision_exit_callback

add_collision_exit_callback(callback: Callable) -> int

Fires once on the frame a collision stops.

add_component

add_component(component_class: Any) -> typing.Any

Attach a new component of the given type to this component's owning Object.

Example
render = self.add_component(RenderComponent)

add_object

add_object(obj: Object, parent: Object = None) -> Object

Add a newly created Object to the scene, optionally parented to another Object

add_shape

add_shape(shape: PolygonShape | RectangleShape | CircleShape, name: str = '') -> int

Add a new collision shape to this component. Returns its shape_id.

Example
sid = col.add_shape(CircleShape(Vector3(0,0,0), 1.0), 'Detector')

get_component

get_component(component_class: Any) -> typing.Any

Look up a component on this Object

get_owner

get_owner() -> Object

The Object that owns this component

get_resolution_shape_id

get_resolution_shape_id() -> int

Get resolution_shape_id. See the resolution_shape_id property.

get_shape

get_shape(shape_id: SupportsInt | SupportsIndex) -> fusion.PolygonShape | fusion.RectangleShape | fusion.CircleShape

Get the Shape object for the shape with the given id

get_shape_area

get_shape_area(shape_id: SupportsInt | SupportsIndex) -> float

Area of the shape with the given id, in world units squared

get_shape_center

get_shape_center(shape_id: SupportsInt | SupportsIndex) -> Vector3

World-space center of the shape with the given id

get_shape_id

get_shape_id(name: str) -> int

Look up a shape's id by its name (as set in the inspector or via set_shape_name). Returns -1 if no shape has that name.

Example
detector_id = self.cc.get_shape_id('Aggro Radius')

get_shape_ids

get_shape_ids() -> list[int]

Returns the ids of every collision shape on this component

get_shape_name

get_shape_name(shape_id: SupportsInt | SupportsIndex) -> str

Get the display name of the shape with the given id

get_sync_with_render_component

get_sync_with_render_component(shape_id: SupportsInt | SupportsIndex) -> bool

Whether the shape with the given id mirrors the RenderComponent shape

has_component

has_component(component_class: Any) -> bool

Check whether this component's owning Object has a component of the given type

is_grounded

is_grounded(probe_length: SupportsFloat | SupportsIndex = 0.15000000596046448) -> bool

Cast a short ray straight down from the lowest point of this shape to check for ground

remove_collision_callback

remove_collision_callback(id: SupportsInt | SupportsIndex) -> None

Unregister a callback previously registered with add_collision_callback()

remove_collision_enter_callback

remove_collision_enter_callback(id: SupportsInt | SupportsIndex) -> None

Unregister a callback previously registered with add_collision_enter_callback()

remove_collision_exit_callback

remove_collision_exit_callback(id: SupportsInt | SupportsIndex) -> None

Unregister a callback previously registered with add_collision_exit_callback()

remove_component

remove_component(component_class: Any) -> None

Remove a component of the given type from this component's owning Object

remove_object

remove_object(obj: Object) -> None

Remove an object from the scene

remove_shape

remove_shape(shape_id: SupportsInt | SupportsIndex) -> None

Remove a collision shape by id, as returned by add_shape()

set_collision_layer

set_collision_layer(layer: SupportsInt | SupportsIndex) -> None

Set collision_layer. See the collision_layer property.

set_collision_mask

set_collision_mask(mask: SupportsInt | SupportsIndex) -> None

Set collision_mask. See the collision_mask property.

set_enable

set_enable(arg0: bool) -> None

Set enable. See the enable property.

set_resolution_shape_id

set_resolution_shape_id(shape_id: SupportsInt | SupportsIndex) -> None

Pass -1 for None: shapes stay collidable for detection, but nothing is physically resolved.

set_shape_name

set_shape_name(shape_id: SupportsInt | SupportsIndex, name: str) -> None

Rename the shape with the given id

set_static

set_static(is_static: bool) -> None

Set is_static. See the is_static property.

CollisionEventData

Snapshot of a single collision, passed to callbacks registered via CollisionComponent.add_collision_callback() and friends.

normal property

normal: Vector3

World-space contact normal, pointing away from self

other property

other: Object

The other Object involved in the collision

other_shape_id property

other_shape_id: int

Id of the colliding shape on other

penetration property

penetration: float

Overlap depth along the contact normal, in world units

point property

point: Vector3

World-space contact point

self property

self: Object

The Object whose CollisionComponent this callback is registered on

shape_id property

shape_id: int

Id of the colliding shape on self, as returned by CollisionComponent.add_shape()

type property

type: CollisionType

The CollisionType (RigidVsRigid, RigidVsSoft, etc.) of this collision

__repr__

__repr__() -> str

RayCastHit

RayCastHit()

Result of a Physics.raycast() query. Falsy (bool(hit) is False) when nothing was hit.

distance property

distance: float

Distance from the ray's origin to the hit point

edge_index property

edge_index: int

Index of the shape edge that was hit

hit property

hit: bool

Whether the ray hit anything

is_soft_body property

is_soft_body: bool

Whether the hit object was a soft body

normal property

normal: Vector3

World-space surface normal at the hit point

object property

object: Object

The Object that was hit, or None if hit is False

point property

point: Vector3

World-space point where the ray hit

__bool__

__bool__() -> bool

Allows 'if hit:' instead of 'if hit.hit:'

__repr__

__repr__() -> str