I have a script which moves a mesh. But I want to do it once. How can I deactivate a trigger when it has already been activated?
I saw this was answered on Discord, but for anybody looking at this later:
The easiest way to stop a trigger from firing events is to set myTrigger.isEnabled = false
or myTrigger.collision = Collision.FORCE_OFF
. The isEnabled
property is basically a shortcut for turning off collision and visibility.
Note that both of those properties can affect your trigger's children, if it has any. If you want those children to remain visible or collidable when the trigger is disabled, you can set their collision and visibility to FORCE_ON. It's probably easiest to do this in the editor ahead of time rather than using Lua.
1 Like