Let’s start by creating a new function, which will contain the whole process (you are free to apply the exact same principles as Events or any other set up). Let’s call it MyPointCloudFunction.

Creating new function in  Blueprint .

Creating new function in Blueprint.

Once the function is ready, add a local variable and call it MyPoints. Set the type of this variable to Point Cloud Point and convert it to an array by right-clicking on the blue bar symbol to the left of the name. This array will hold our intermediate data.

// Create an empty array to hold the points
TArray<FPointCloudPoint> MyPoints;
Create local array to hold the data.

Create local array to hold the data.


Now we can proceed to build the actual process, starting with populating our newly created array. For the purpose of this example, the array will be injected with 1000 randomly positioned, red points.

// Populate the MyPoints array with 1000 randomly positioned, red points
for (int32 i = 0; i < 1000; i++)
{
    // See FPointCloudPoint for more constructor versions
    MyPoints.Emplace(FMath::VRand(), FColor::Red, true);
}
Populate the array with 1000 randomly positioned, red points.

Populate the array with 1000 randomly positioned, red points.


Now we need to construct an empty Point Cloud asset to assign the point data to. We will also save it as a local variable for later use.

// Construct an empty Point Cloud asset
UPointCloud *MyPointCloud = NewObject<UPointCloud>();
Construct an empty Point Cloud asset.

Construct an empty Point Cloud asset.


Following this, we need to assign our populated array as data for this Cloud. We will also automatically rebuild all internal structures for the data.

Alternatively, you can opt for not rebuilding the Cloud straight away, and instead manually call the Rebuild function at some other time.

// Assign the generated points to the cloud and automatically rebuild the data
MyPointCloud->SetPointCloudData(MyPoints);
// Alternatively, do not auto-build the data by calling
// MyPointCloud->SetPointCloudData(MyPoints, false);
Assign and build data.

Assign and build data.


At this point you can do with the asset as you would with one imported through the Content Browser. In this example, we'll assign it to some hypothetical Point Cloud Actor.

// Get the target Point Cloud Actor
APointCloudActor *MyPointCloudActor = MyActorGettingFunction();

// Assign the constructed Cloud
MyPointCloudActor->GetPointCloudComponent()->SetPointCloud(MyPointCloud);
Assign the Cloud asset to a Point Cloud Actor.

Assign the Cloud asset to a Point Cloud Actor.


And that’s it - once the code or Blueprint is executed you should have a brand new, sphere-shaped, red Point Cloud, like this:

Final result.

Final result.


Here are the full code snippet and full-sized Blueprint screenshot of the complete process.

// Create an empty array to hold the points
TArray<FPointCloudPoint> MyPoints;

// Populate the MyPoints array with 1000 randomly positioned, red points
for (int32 i = 0; i < 1000; i++)
{
    // See FPointCloudPoint for more constructor versions
    MyPoints.Emplace(FMath::VRand(), FColor::Red, true);
}

// Construct an empty Point Cloud asset
UPointCloud *MyPointCloud = NewObject<UPointCloud>();

// Assign the generated points to the cloud and automatically rebuild the data
MyPointCloud->SetPointCloudData(MyPoints);
	
// Get the target Point Cloud Actor
APointCloudActor *MyPointCloudActor = MyActorGettingFunction();

// Assign the constructed Cloud
MyPointCloudActor->GetPointCloudComponent()->SetPointCloud(MyPointCloud);

Complete Blueprint of the function.