I’m making a custom ActorComponent in C++ and want to have a parameter for UBoxComponent to select in a blueprint later.
But In the blueprint it’s only available to select a new (??) Box Collision in the dropdown, and I don’t see a way to select existing box component…
What’s wrong with it and how to make it properly?
Look for the screenshot: (“Volume” is a UBoxComponent)
In any cases I see only “None” and “Box Collision” items in the dropdown. Also if I choose “Box Collision” – it somehow adds a new box into the scene…
And that’s how I define the custom component:
#pragma once
#include "Components/ActorComponent.h"
#include "SpawnComponent.generated.h"
UCLASS( ClassGroup=(Spawn), meta=(BlueprintSpawnableComponent) )
class SHOOTEMUP_API USpawnComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
USpawnComponent();
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
protected:
// Called when the game starts
virtual void BeginPlay() override;
private:
UPROPERTY(EditAnywhere, Category = "Spawn")
TSubclassOf<APawn> PawnClass;
UPROPERTY(EditAnywhere, Category = "Spawn")
UBoxComponent* SpawnBox = nullptr;
float LastSpawnedTime = 0;
FVector GetSpawnLocation();
APawn* SpawnAtLocation(FVector Location);
};