Skip to reading
Shaders, Effects & Layered Scenery

69. A complete script to stop and release it

Edition 0.86.4.0

Revised 0.86.4.0 edition with new supplements; earlier 0.86.3.4 lessons and screenshot labels are retained within the supplied PDF.

Download PDFView PDF page
Code example
extends PCAScriptBase
Code example
func run() -> void:
    await ChangeObjectProperty({"entityId":"hand_orb",
        "property":"particle.enabled","value":false})
    await SetObjectVisible({"entityId":"hand_orb","visible":false})
    await DetachParticleEffect({"entityId":"hand_orb"})

Create this as a separate enabled GDScript record, ID effect_off. Assign it to the stop button or ability-ending event. Hiding the ball gives an immediate visual ending; disabling emission and detaching release its active behavior.

Source table from 69. A complete script to stop and release it, page 73
If you want…Adapt the ending
The aura to disappear immediatelyDisable emission, hide the source and detach when no link is needed.
A smoke trail to fade naturallyStop new emission and keep the emitter visible until the old particles have expired.
The effect to remain attached but inactiveDisable emission and keep the attachment. Re-enable it later.
A dropped effect to remain in the roomDetach at its current pose and choose whether it should keep emitting.

Do not copy the hide step into every effect without thinking about the desired tail. A tiny hand aura and a long smoke plume have different useful endings.

The example’s enable script makes the emitter visible again before restarting it. A visible=false source remains hidden even when you change its particle emission back to true.

Page 73 of 93Permalink
Go to page