Skip to content

Latest commit

 

History

History
132 lines (76 loc) · 4.59 KB

trigger_collision_manager.md

File metadata and controls

132 lines (76 loc) · 4.59 KB

TriggerCollisionManager

from tdw.add_ons.trigger_collision_manager import TriggerCollisionManager

Listen for trigger collisions between objects.


Fields

  • trigger_ids A dictionary of trigger colliders. Key = The trigger ID. Value = The object ID.

  • collisions A list of TriggerCollisionEvent from this frame.

  • commands These commands will be appended to the commands of the next communicate() call.

  • initialized If True, this module has been initialized.


Functions

__init__

TriggerCollisionManager()

(no parameters)

get_initialization_commands

self.get_initialization_commands()

This function gets called exactly once per add-on. To re-initialize, set self.initialized = False.

Returns: A list of commands that will initialize this add-on.

on_send

self.on_send(resp)

This is called after commands are sent to the build and a response is received.

Use this function to send commands to the build on the next frame, given the resp response. Any commands in the self.commands list will be sent on the next frame.

Parameter Type Default Description
resp List[bytes] The response from the build.

before_send

self.before_send(commands)

This is called within Controller.communicate(commands) before sending commands to the build. By default, this function doesn't do anything.

Parameter Type Default Description
commands List[dict] The commands that are about to be sent to the build.

get_early_initialization_commands

self.get_early_initialization_commands()

This function gets called exactly once per add-on. To re-initialize, set self.initialized = False.

These commands are added to the list being sent on communicate() before any other commands, including those added by the user and by other add-ons.

Usually, you shouldn't override this function. It is useful for a small number of add-ons, such as loading screens, which should initialize before anything else.

Returns: A list of commands that will initialize this add-on.

add_box_collider

self.add_box_collider(object_id, position, scale)

self.add_box_collider(object_id, position, scale, rotation=None, trigger_id=None)

Add a box-shaped trigger collider to an object.

Parameter Type Default Description
object_id int The ID of the object.
position Dict[str, float] The position of the trigger collider relative to the parent object.
scale Dict[str, float] The scale of the trigger collider.
rotation Dict[str, float] None The rotation of the trigger collider in Euler angles relative to the parent object. If None, defaults to {"x": 0, "y": 0, "z": 0}.
trigger_id int None The unique ID of the trigger collider. If None, an ID will be automatically assigned.

Returns: The ID of the trigger collider.

add_cylinder_collider

self.add_cylinder_collider(object_id, position, scale)

self.add_cylinder_collider(object_id, position, scale, rotation=None, trigger_id=None)

Add a cylinder-shaped trigger collider to an object.

Parameter Type Default Description
object_id int The ID of the object.
position Dict[str, float] The position of the trigger collider relative to the parent object.
scale Dict[str, float] The scale of the trigger collider.
rotation Dict[str, float] None The rotation of the trigger collider in Euler angles relative to the parent object. If None, defaults to {"x": 0, "y": 0, "z": 0}.
trigger_id int None The unique ID of the trigger collider. If None, an ID will be automatically assigned.

Returns: The ID of the trigger collider.

add_sphere_collider

self.add_sphere_collider(object_id, position, diameter)

self.add_sphere_collider(object_id, position, diameter, trigger_id=None)

Add a sphere-shaped trigger collider to an object.

Parameter Type Default Description
object_id int The ID of the object.
position Dict[str, float] The position of the trigger collider relative to the parent object.
diameter float The diameter of the trigger collider.
trigger_id int None The unique ID of the trigger collider. If None, an ID will be automatically assigned.

Returns: The ID of the trigger collider.

reset

self.reset()

Reset this add-on. Call this before resetting a scene.