Hology
Hology
Hology
  • 👋Welcome to Hology Docs
  • Getting started
    • Introduction to Hology
    • The first steps
    • Editor basics
      • Flying in scenes
      • Placing objects
      • Select objects
      • Transform
      • Grouping objects
      • Duplicate
    • Starter project - Third person shooter
  • Tutorials
    • Rolling ball - Gameplay programming
    • Character movement programming
    • Character AI behavior
  • Release
    • Distribution
      • Discord Activities
      • Facebook Instant Games
      • Upload to Itch.io
      • Host with GitHub Pages
      • Publishing to Steam
      • iOS and Android
  • Assets
    • 3D Models
      • Custom collision shapes
      • Material slots
    • Materials
    • Textures
    • Prefabs
  • Gameplay
    • Actors
      • Creating actor classes
      • Actor parameters
      • Actor components
      • Actor lifecycle
      • Spawning actors
      • Moving actors
    • Services
      • Load assets
    • Player input
    • Collision detection
    • Physics
      • Physics body types
      • Applying forces
      • Ray casting
    • Trigger volumes
    • Character movement
    • Pointer events
    • Animation
      • Animation system
      • Character Animation
      • Animation State Machine
    • Sound
      • Audio parameter
    • World
    • Navigation
  • Shaders
    • Introduction to shaders
    • Creating shaders
    • Shader parameters
    • Typescript shaders
      • Types
      • Math functions
      • Attributes
      • Varying
      • Uniforms
      • Textures
      • Arrays
      • Select
      • Lighting
    • Painted materials
    • Water shader tutorial
  • Level design
    • Landscape sculpting
    • Landscape painting
    • Grass
  • User Interfaces
    • Creating user interfaces
    • Using React
    • VR
  • Visual Effects
    • Introduction to VFX
    • VFX Assets
  • Integrations
    • Arcweave
Powered by GitBook
On this page
  • Creating trigger volumes
  • TriggerVolumeActor
  • TriggerVolumeComponent
  • Handling trigger volume events
  1. Gameplay

Trigger volumes

Trigger volumes is a type of volume that you can place within your game world to detect when other objects or characters enter or exit it. Trigger volumes are commonly used in games for various purposes, such as triggering events or activating gameplay mechanics.

Creating trigger volumes

TriggerVolumeActor

A trigger volume actor can be placed as an object in your scene. You can find it in the asset browser under actors. You can then refer to the trigger volume actor by adding it as a parameter to another actor.

TriggerVolumeComponent

A trigger volume can be created by attaching a TriggerVolumeComponent to an actor. The trigger volume is a box so you need to provide the dimensions of it.

Handling trigger volume events

Whenever an actor enters or exists a trigger volume, you can trigger some functionality. In the example below, every time the Character actor overlaps with a Coin actor, it increases the number of collected coins bye one and then removes the coin actor from the world.

@Actor()
class Character extends BaseActor {
    private physicsSystem = inject(PhysicsSystem)
    private world = inject(World)
    
    collectedCoins: number = 0

    onInit() {
        this.physicsSystem.onBeginOverlapWithActorType(this, Coin)
            .subscribe(coin => {
                this.collectedCoins++
                world.remove(coin)                
            })
    }
}

@Actor()
class Coin extends BaseActor {
    private triggerVolume = attach(TriggerVolumeComponent, { 
        dimensions: new Vector3(1, 1, 1) 
    })
}

PreviousRay castingNextCharacter movement

Last updated 11 months ago