pabloflmetaAnswer
Meta Employee
April 9, 2025
Hi there! I've done some experimentation, and I've found a solution to disabling a trigger after a player interacts with it. Here's a code example that should help:
import { Component, TriggerGizmo, CodeBlockEvents, Player } from 'horizon/core';
class DisableTriggerOnEnter extends Component<typeof DisableTriggerOnEnter> {
start() {
const triggerGizmo = this.entity.as(TriggerGizmo)!;
if (triggerGizmo) {
this.connectCodeBlockEvent(this.entity, CodeBlockEvents.OnPlayerEnterTrigger, (player: Player) => {
console.log('Player entered trigger');
triggerGizmo.enabled.set(false);
});
}
}
}
Component.register(DisableTriggerOnEnter);
This worked for me on my end, but I hope this helps with your issue, if you need any additional assistance, please let me know.
