Header file:
// Authored by me
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/PointLightComponent.h"
#include "DestructibleComponent.h"
#include "Test.generated.h"
UCLASS()
class UNREALARCHERYSHOOTER_API ATest : public AActor
{
GENERATED_BODY()
public:
ATest();
protected:
virtual void BeginPlay() override;
private:
UPROPERTY(EditAnywhere)
UDestructibleComponent* DestructibleComponent;
UPROPERTY(EditAnywhere)
UPointLightComponent* Light;
};
.cpp file (just comment and include header else)
// Authored by me
#include "Test.h"
ATest::ATest()
{
DestructibleComponent = CreateDefaultSubobject<UDestructibleComponent>("DMComp");
Light = CreateDefaultSubobject<UPointLightComponent>("Light");
DestructibleComponent->SetSimulatePhysics(true);
GLog->Log(DestructibleComponent->IsSimulatingPhysics() ? TEXT("true") : TEXT("false")); // shows "false"
RootComponent = DestructibleComponent;
Light->SetupAttachment(RootComponent);
}
void ATest::BeginPlay()
{
Super::BeginPlay();
GLog->Log(DestructibleComponent->IsSimulatingPhysics() ? TEXT("true") : TEXT("false")); // Shows "false"
DestructibleComponent->SetSimulatePhysics(true); // without this line Actor does not fall down
GLog->Log(DestructibleComponent->IsSimulatingPhysics() ? TEXT("true") : TEXT("false")); // Shows "false", but actor falls down
}