Hello everyone,
I have created a Blueprint, where there is a static mesh and a box collision. The static mesh in this case is a door and the box collision will open it when the player overlaps it.
Now my problem is that I created an OpenDoor Component in C++, my Component needs to be associated (added as component) to the actor you want to rotate. But there’s isn’t “Add to component” to the static mesh in the blueprint. I have no way of adding my C++ component to my static mesh, here’s an image of what I’m talking about:
https://imgur.com/a/3Gu44gC
How can I make this work? Do I need to change my Open Door component to take a static mesh and how? Or is there a simple fix?
I have exposed my OpenDoor and CloseDoor method of my C++ component with UFUNCTION(BlueprintCallable)
My OpenDoor component header :
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MYPROJECT_API UOpenDoor : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UOpenDoor();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
void OpenDoor(float DeltaTime);
void CloseDoor(float DelaTime);
private:
float InitialYaw;
float CurrentYaw;
UPROPERTY(EditAnywhere)
float OpenAngle = 90.0f;
UPROPERTY(EditAnywhere)
ATriggerVolume* PressurePlate;
UPROPERTY(EditAnywhere)
AActor* ActorThatOpens;
float DoorLastOpened = 0.f;
UPROPERTY(EditAnywhere)
float DoorCloseDelay = 0.5f; // half a second
UPROPERTY(EditAnywhere)
float DoorOpenSpeed = 0.8f;
UPROPERTY(EditAnywhere)
float DoorCloseSpeed = 2.0f;
};
Thank you for reading!
mBrock
(mBrock)
March 2, 2020, 5:28pm
2
Not 100% sure based on what you posted here. But I’m assuming the blueprint is an Actor or child of an actor. You have to add an actorcomponent to an actor (The blueprint itself) not the static mesh. The static mesh is a component of the blueprint as well.
https://docs.unrealengine.com/en-US/Gameplay/HowTo/AddingComponents/Blueprints/index.html
As long as you compiled your code. That component should show up in the add component list
mBrock:
Not 100% sure based on what you posted here. But I’m assuming the blueprint is an Actor or child of an actor. You have to add an actorcomponent to an actor (The blueprint itself) not the static mesh. The static mesh is a component of the blueprint as well.
Adding Components to an Actor in Unreal Engine | Unreal Engine 5.3 Documentation
As long as you compiled your code. That component should show up in the add component list
Thanks mBrock, I’ll try this and tell you how it goes. Thank you
mBrock:
Not 100% sure based on what you posted here. But I’m assuming the blueprint is an Actor or child of an actor. You have to add an actorcomponent to an actor (The blueprint itself) not the static mesh. The static mesh is a component of the blueprint as well.
Adding Components to an Actor in Unreal Engine | Unreal Engine 5.3 Documentation
As long as you compiled your code. That component should show up in the add component list
When I add a Child Actor Component to my Blueprint, I still can’t add a C++ Component to it. The Child Actor Component takes only Blueprint. Any help?
mBrock
(mBrock)
March 10, 2020, 2:27pm
6
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "DVCharacterBuffsComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class DEUSVOX_API UDVCharacterBuffsComponent : public UActorComponent
{
GENERATED_BODY()
public: // Sets default values for this component's properties UDVCharacterBuffsComponent();
protected: // Called when the game starts virtual void BeginPlay() override;
public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};
Humm i looked at one of my old projects … and this code lets me add it to a blueprint … so yours looks good.
mBrock
(mBrock)
March 10, 2020, 2:34pm
7
Maybe create a child blueprint from the cpp file? in the content browser right click and select create blueprint based on this … then use the child to add it…
Not the ideal way … but might be a temp work around