Download

Custom component problem

I created a custom component, child of USkeletalMeshComponent. This is the header file right now:



#pragma once

#include "Components/SkeletalMeshComponent.h"
#include "CharacterSymbolComponent.generated.h"

/**
 * 
 */
UCLASS()
class DDCHARTEST_API UCharacterSymbolComponent : public USkeletalMeshComponent
{
	GENERATED_BODY()

public:
	//
	void InitSymbol(bool bShouldFaceCamera = true);

	//
	//UPROPERTY(EditAnywhere)
		bool bFaceCamera;

	//
	UPROPERTY(EditAnywhere)
		FTransform OriginalTransform;

private:

public:
	//
	virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction) override;
};


I just declared a few variables and overrided the TickComponent function.
After I create the component in my character constructor (CreateDefaultSubobject<>(…)) I call the InitSymbol function (a very simple function ↓):



void UCharacterSymbolComponent::InitSymbol(bool bShouldFaceCamera)
{
	// Force the component to call TickComponent
	PrimaryComponentTick.bCanEverTick = true;

	bFaceCamera = bShouldFaceCamera;
}


Then, if I try to open the character blueprint that has this character class as a parent the editor freezes (I can see on the task manager that the used memory starts to increase and I’m forced to kill the process from the task manager).
After a few tests I found out that the problem is: bFaceCamera = bShouldFaceCamera;

What’s wrong with it?

(I’m using Unreal 4.7.6)

Hey there,

could it be that your component might be null?

Did you attached it the root/orwhatever component in order to prevent garbage collection? i cant tell since i dont see your character constructor.

I also would add the meta=“BlueprintSpawnableComponent” to your UCLASS as a specifier.

kind regards
Wallhalla