components.create
Creates and initializes an actor component from a native or Blueprint class.
Top-level alias: ue.create_component.
Syntax
ue.components.create(
actor: ActorReference,
component_class: string | UObjectProxy,
options?: table
) -> UObjectProxy?, string?Parameters
| Parameter | Type | Description |
|---|---|---|
actor | ActorReference | Actor proxy, string query, or actor descriptor. |
component_class | string | UObjectProxy | Native/generated Blueprint UActorComponent class path or a UClass proxy. |
options.manual_attachment | boolean? | Skip Unreal's automatic root attachment. Default: false. |
options.properties | table? | Reflected component properties to write immediately after creation. |
Returns
| Type | Description |
|---|---|
UObjectProxy | The newly created and registered component. |
nil, string | Validation, creation, or property initialization failed. |
Example
local character = assert(ue.get_player_character())
local light = assert(ue.create_component(
character,
"/Script/Engine.PointLightComponent",
{
properties = {
Intensity = 5000,
AttenuationRadius = 900
}
}
))Use a generated class path ending in _C for Blueprint component classes.
If a property write fails, the new component is destroyed and the function returns nil, error; partially initialized components are not left on the actor.
Creation requires Unreal's reflected AActor.AddComponentByClass function. An engine version that does not expose it returns a descriptive error.