Skip to reading
3D Models & Video in GUIs

12. Change the clip, view or model

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

Play a particular embedded clip with the shared action. This example is a complete small GDScript record:

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    await PlayGUIModelAnimation({
        "guiId": "animation_lab",
        "elementId": "avatar_viewer",
        "animation": "PCA_OpenHands",
        "loop": true,
        "speed": 1.0
    })
    return true

To stop the viewer animation, use Change GUI Element Property with property modelAnimated and value false. To change an authored view, use a property such as modelInitialView with the value left.

Code example
await ChangeGUIElementProperty({
    "guiId": "model_lab",
    "elementId": "object_viewer",
    "property": "assetId",
    "value": "owl_model"
})

The second example belongs inside a run function. It swaps the loaded model asset while keeping the element ID. After swapping, check framing and clip selection: an animation name from the old model may not exist in the new one.

Changing view fields reapplies the starting view and can clear temporary player orbit/pan. Use those changes deliberately, not every frame while the player is inspecting the object.

Page 20 of 45Permalink
Go to page