Making Custom Components

Hello everyone :slight_smile:
I am trying to make custom components and have them sit in the blueprint menu

d0fa958a0377ad4977512667ecbe456c4c9b3fb8.jpeg

Does anyone know the correct way to do this?
For example, how would i make a component with a light and a mesh.

im looking to create nested blueprints i guess, in a way. I have rooms set up as blueprints and need to insert custom game features into my room blueprints. I was using add child actor but it is limited. if my rooms where in the world i could just use AActors no problem but i need to be able to edit there default values inside of the blueprint component window.

My progress,

2e1686059fe212456ae587bbfc84b88a5dfd430d.jpeg

I have managed to get my own things into the menu by adding this to the UCLASS to a USceneComponent


	UCLASS(ClassGroup = JacksCustom, editinlinenew, meta = (BlueprintSpawnableComponent))

both editinlinenew and BlueprintSpawnableComponent are key here.

Not only that but by adding this to a UPointLightComponent i am able to make a custom light and effect its values with code. Neat!

However unreal crashes when i try to add anything, so for example this code builds fine but when you try to add the component into a blueprint it will crash;


	

// .h

#pragma once

#include "Components/PointLightComponent.h"
#include "MyCustomLightComponent.generated.h"

/**
 * 
 */
UCLASS(ClassGroup = Jacks, editinlinenew, hidecategories = (Object, LOD, Lighting, TextureStreaming), meta = (BlueprintSpawnableComponent))
class UMyCustomLightComponent : public UPointLightComponent
{
	GENERATED_UCLASS_BODY()

	UPROPERTY(VisibleAnywhere, Category = "Power")
	TSubobjectPtr<USphereComponent> SphereCore;
	
};




//.cpp
#include "HorrorGame.h"
#include "MyCustomLightComponent.h"


UMyCustomLightComponent::UMyCustomLightComponent(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	SphereCore = PCIP.CreateEditorOnlyDefaultSubobject<USphereComponent>(this, TEXT("SphereCore"));
	SphereCore->InitSphereRadius(35.0f);
}



271fa640e7c941fc530564e72f4989605ed9c6e9.jpeg

Hi Staggerlee,

I’m not entirely sure why it’s crashing, but the particular problem there is that Outer is NULL and it’s being dereferenced. Can you walk up the call stack and see where Outer is coming from?

Cheers,
Michael Noland

Michael , my apologies for my terminology. Unreal Engine breaks, not crashes.
I am passing itself to outer,


PCIP.CreateEditorOnlyDefaultSubobject<USphereComponent>(this, TEXT("SphereCore"));

This works fine when the parent is an AActor, but my guess is the issue may be that i cannot have components in components or something like that.

I think my issue is hierarchy, is my current method the correct way to achieve the effect i want? am i using the correct parent ‘Actor Component’ to do this?

another example, if i wanted to put in a point light that has a float, and each tick the float goes down till it is 0, then the light turns off. I would then like to put this light into many blueprints, so i could make it as a blueprint then add it as a child actor but i wont be able to edit that float value for each light. So by making my own cusom compnent that is a light with a float exposed to the blueprint editor i solve my problem.

No progress with this,

is there a better way say create a nested blueprint then using a child actor or making a custom component?

i have started to breakdown the class.cpp document. Its hard to fully know whats going on with my experience level here.
However it seems to break when ConstructObject is called and Template is equal to NULL.

i will keep exploring and trying things at random, but does anyone know if custom components and even generate there own components in this way?


UMyCustomLightComponent::UMyCustomLightComponent(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	SphereCore = PCIP.CreateEditorOnlyDefaultSubobject<USphereComponent>(this, TEXT("SphereCore"));
	SphereCore->InitSphereRadius(35.0f);
}

also, for people who find this post, editinlinenew is not required, just meta = (BlueprintSpawnableComponent).

i have reread this many times Components | Unreal Engine Documentation
And have experimented with UActorComponent::OnRegister(), as well as a few other things. Theres no example i can find however! Would downloading the engine source help here? i would love to look at the .cpp file of say the light component.

Any help at all would be appreciated. im sorry if this thread is turning to spaghetti but i am reporting all of my findings here so show my process and hopefully enable a response. If i have been unclear let me know!

Edit:
After seeing this, is this the tool that i am waiting for?

Or am i going about things the right way?

Any news here? It’s still not possible to nest configurable Blueprints. Acor components are no solution, they aren’t allowed to react to input and I cannot use timelines in them which make them essentially useless for me.