From eb81971ae1e108d23a0daec66a53e0191733c8cd Mon Sep 17 00:00:00 2001 From: Arthur Shir Date: Sun, 16 Feb 2025 11:55:34 -0500 Subject: [PATCH] [iss_6] Add documentation for behavior collisions --- pages/behaviors.mdx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/pages/behaviors.mdx b/pages/behaviors.mdx index 294d973..6ba9b9a 100644 --- a/pages/behaviors.mdx +++ b/pages/behaviors.mdx @@ -5,7 +5,7 @@ Behaviors are reusable scripts that attach directly to existing Components in aw --- -## Minimal Behavior +## Minimal Example 1. **Create a new script** with: ```ts @@ -19,7 +19,7 @@ Behaviors are reusable scripts that attach directly to existing Components in aw --- -## Adding Actions +### Adding Actions For a simple rotation, add `onUpdate`: @@ -34,6 +34,20 @@ onUpdate(dt: number) { --- +### Adding Collisions + +For a simple collision, add `handleCollisionEnter`: + +```ts +handleCollisionEnter(event: CollisionEvent) { + console.log("Collision detected!"); +} +``` + +> **Note:** Collision settings defined on parent components take precedence over those defined in behaviors. So when using the GUI editor, ensure that collisions are enabled only on the behavior script and not the parent component. + +--- + ## Frontend Customization (Parameters) Expose settings to the Studio UI using params: @@ -56,7 +70,7 @@ Users can now adjust `speed` in the Inspector. --- -## Organizing UI with Folders +### Organizing Studio UI with Folders Use `@Folder` to group parameters: @@ -74,7 +88,7 @@ export default class ExampleBehavior extends ScriptBehavior { --- -## Config +### Config You can add descriptive metadata: