Download

OnComponentBeginOverlap doesn't work in UE 4.20.3!

Hello again, another noob question from a new-starter.

I was following a tutorial from a site where you simply create bunch of static meshes moving along an axis.When you hit the meshes, you will be teleported to your started position.My Problem is with the onComponentBeginOverlap function in the UE 4 C++ api. I tried the exact steps and couldn’t manage this to work.Can anybody help?

MyActor.h



// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/ShapeComponent.h"
#include "Components/BoxComponent.h"
#include "Components/PrimitiveComponent.h"
#include "MyActor.generated.h"



UCLASS()
class TUT_FPSHORROR_API AMyActor : public AActor
{
    GENERATED_BODY()

public:    
    // Sets default values for this actor's properties
    AMyActor();
    UPROPERTY(EditAnywhere)
        UShapeComponent* SC_Root;

    UPROPERTY(EditAnywhere)
        UStaticMeshComponent* SM_MyMesh;
    UPROPERTY(EditAnywhere)
        float flSpeedScale;
    UPROPERTY(EditAnywhere)
        FVector Vec3dPlayerStart;

    UFUNCTION()
        void TriggerEnter(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public:    
    // Called every frame
    virtual void Tick(float DeltaTime) override;
    float FlTime;


};



MyActor.cpp



// Fill out your copyright notice in the Description page of Project Settings.

#include "MyActor.h"


// Sets default values
AMyActor::AMyActor()
{
     // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;
    SC_Root = CreateDefaultSubobject<UBoxComponent>(TEXT("Root"));

    SC_Root->GetGenerateOverlapEvents();
    SC_Root->OnComponentBeginOverlap.AddDynamic(this, &AMyActor::TriggerEnter);
    RootComponent = SC_Root;

    SM_MyMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MyMesh"));
    SM_MyMesh->AttachTo(RootComponent);

    Vec3dPlayerStart = FVector(-350.0f, -99.0f, 235.0f);
    flSpeedScale = 45.0f;



}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
    Super::BeginPlay();


}

// Called every frame
void AMyActor::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    FVector Loc = GetActorLocation();
    float DeltaHeight = FMath::Sin(FlTime + DeltaTime) - FMath::Sin(DeltaTime);
    Loc.Y += DeltaHeight * flSpeedScale;
    FlTime += DeltaTime;
    AMyActor::SetActorLocation(Loc);

}

//void AMyActor::TriggerEnter(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
//{
//    OtherActor->SetActorLocation(Vec3dPlayerStart);
//}


Screenshot of the errors:

BeginOverlapError.jpg