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
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)
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_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_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_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_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
CollisionEventData ¶
Snapshot of a single collision, passed to callbacks registered via CollisionComponent.add_collision_callback() and friends.
RayCastHit ¶
RayCastHit()
Result of a Physics.raycast() query. Falsy (bool(hit) is False) when nothing was hit.