Creating a custom Primitive Component
Primitive
components are the most complex type of Actor
Component because they not only have a transform, but are also rendered on screen.
How to do it...
- Create a custom C++ class based on
MeshComponent
. When Visual Studio loads, add the following to your class header file:UCLASS(ClassGroup=Experimental, meta = (BlueprintSpawnableComponent)) public: virtual FPrimitiveSceneProxy* CreateSceneProxy() override; TArray<int32> Indices; TArray<FVector> Vertices; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Materials) UMaterial* TheMaterial;
- We need to create an implementation for our overridden
CreateSceneProxy
function in our cpp file:FPrimitiveSceneProxy* UMyMeshComponent::CreateSceneProxy() { FPrimitiveSceneProxy* ...
Get Unreal Engine 4 Scripting with C++ Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.