Player Script component
Player Script allows you to use scripts to control players and devices.
Player Scripts can be used by calling ClusterScript.setPlayerScript()
in the Scriptable Item API.
Properties
properties | function |
---|---|
Source Code Asset | An asset can specify the script content that represents the item’s behavior. |
Source Code | You can directly specify the contents of the script that represents the behavior of the item. |
The content of the script is written in JavaScript.
Specify either Source Code Asset
or Source Code
. If both are specified, the content of Source Code Asset
takes precedence.
detail
Each item can have up to one Player Script component. They can also coexist with components of other types of items.
See Script Reference for APIs that can be used in scripts.
For sample code of Player Script, please refer to Variable _.
When spaces or worlds are updated
When a space instance such as Space or Event is updated, the PlayerScript
is updated and re-evaluated.
The following states will be discarded at this time:
- Variables declared in the
PlayerScript
script - The button displayed by PlayerScript.showButton()
- The camera position set using CameraHandle
If you want to maintain the state across updates to a space instance such as space or event, please use Player Storage.
Other points to note
- Player Script don’t work in world preview