I’m trying to create a Crumbling Platform in UE5.3. I noticed that in UE4, the object had proper collision (no overlap), but in UE5, the character is overlapping/falling through it. Does anyone have suggestions on how to fix this collision issue?" (It just not a only collision Issue, I use pawn)
//.h file
#pragma once
#include "CoreMinimal.h"
//#include "Platform/MovingPlatform.h"
#include "GameFramework/Actor.h"
#include "CrumblePlatform.generated.h"
/**
*
*/
UCLASS()
class UE5_GAMEPLAYSYSTEMS_API ACrumblePlatform : public AActor //AMovingPlatform
{
GENERATED_BODY()
public:
ACrumblePlatform();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
//Components
UPROPERTY(VisibleAnyWhere)
class UBoxComponent* TriggerBox;
UPROPERTY(EditAnyWhere)
class UGeometryCollectionComponent* Platform; //UE5+ Version
//UPROPERTY(VisibleAnywhere)
//class UDestructibleComponent* Platform; //UE4 Version
// Trigger Function
UFUNCTION()
void OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
bool bFromSweep, const FHitResult& SweepResult);
// Sequnce Function
void StartCrumbling();
void FinalBreak();
FTimerHandle CrumbleTimerHandler;
FTimerHandle FinalBreakTimerHandler;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
//.cpp file
#include "Platform/CrumblePlatform.h"
#include "Components/BoxComponent.h"
//#include "DestructibleComponent.h"
#include "GeometryCollection/GeometryCollectionComponent.h"
ACrumblePlatform::ACrumblePlatform()
{
PrimaryActorTick.bCanEverTick = true;
//Initializ Box Trigger
TriggerBox = CreateDefaultSubobject<UBoxComponent>("TriggerBox");
//RootComponent = TriggerBox;
TriggerBox->SetupAttachment(RootComponent);
TriggerBox->OnComponentBeginOverlap.AddDynamic(this, &ACrumblePlatform::OnOverlapBegin);
//Initialize Fractured Mesh
Platform = CreateDefaultSubobject<UGeometryCollectionComponent>("Platform"); UE5
//Platform = CreateDefaultSubobject<UDestructibleComponent>("Platform");// UE4
Platform->SetupAttachment(TriggerBox);
}
void ACrumblePlatform::BeginPlay()
{
Super::BeginPlay();
}
void ACrumblePlatform::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ACrumblePlatform::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
// Check if it's the player (optional check)
if (OtherActor && OtherActor->IsA(APawn::StaticClass()))
{
UE_LOG(LogTemp, Error, TEXT("Trigger"));
// Start the first delay (e.g., 2 seconds before parts drop)
GetWorldTimerManager().SetTimer(CrumbleTimerHandler, this, &ACrumblePlatform::StartCrumbling, 2.0f, false);
}
}
void ACrumblePlatform::StartCrumbling()
{
UE_LOG(LogTemp, Error, TEXT("StartCrumblig"));
Platform->SetSimulatePhysics(true);
GetWorldTimerManager().SetTimer(FinalBreakTimerHandler, this, &ACrumblePlatform::FinalBreak, 3.0f, false);
}
void ACrumblePlatform::FinalBreak()
{
UE_LOG(LogTemp, Error, TEXT("Final Brack"));
Platform->SetAllPhysicsLinearVelocity(FVector(0, 0, -100));
//Platform->ApplyRadiusDamage(5000.f, GetActorLocation(), 500.f, 2000.f, true);
}
Hole code Successfully compiled No error show in code.
UE4
UE5

