Skip to main content

SET

Constant SET 

Source
pub const SET: FunctionDescriptor;
Expand description

Replaces an existing record component on an entity.

C means a concrete type value. set requires that component to exist already and replaces it atomically; use add for a new component.

§Signature

func set(entity: Entity, component: C) -> Unit

§Replace a component

set updates an already attached component.

let entity = spawn(Vec3 {});
set(entity, Vec3 { x: 2 });
print(get[Vec3](entity).x);