Skip to reading
Shaders, Effects & Layered Scenery

68. A complete script to enable the hand effect

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

Create an enabled GDScript record named Enable Hand Effect, ID effect_on. Keep it non-global with no automatic event subscriptions, then call it from the button or interaction you choose.

Code example
extends PCAScriptBase
Code example
func run() -> void:
    var linked: bool = await AttachParticleEffect({
        "entityId":"hand_orb", "targetId":"player",
        "targetPoint":"right_hand_grip", "offset":[0,0.04,0]
    })
    if not linked:
        return
    await SetObjectVisible({"entityId":"hand_orb","visible":true})
    await ChangeObjectProperty({"entityId":"hand_orb",
        "property":"particle.enabled","value":false})
    await ChangeObjectProperty({"entityId":"hand_orb",
        "property":"particle.enabled","value":true})

The script first checks that the attachment succeeded. It then makes the source visible and restarts its emission. This handles an effect that was previously hidden or used once already.

Replace the IDs and point name with your own. The player alias follows the currently active player; an explicit ada target always requests that live instance. The example requires the emitter and target to exist in the same loaded room.

This is project script code using PCAScriptBase. It belongs in a script record, not in the engine source or a shader source file.

Page 72 of 93Permalink
Go to page