Replaces an existing record component on an entity.
Signature
C means a concrete type value. set requires that component to exist already and replaces it atomically; use add for a new component.
Parameters
entity: Entity- An entity that already has the component type.
component: C- The replacement type value.
Returns
UnitUnit after the replacement is accepted.
Examples
Replace a component
set updates an already attached component.
main.kj
Loading…Drag to orbit · select to inspect
0 entities
Scene controls
Results
Loading the language runtime…
Output 0
No output.
State
Compile source to inspect its values.
TraceNo execution yet
- Executed source spans appear here.
Expected output
2
Rust definition
Rust interpreter builtin dispatch; Type is specialized from the concrete component type.
View Rust documentation →Support: runtime