Crash Screenshot:-
Mover.CPP file -
// Fill out your copyright notice in the Description page of Project Settings.
#include "Mover.h"
#include "Math/UnrealMathUtility.h"
// Sets default values for this component's properties
UMover::UMover()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UMover::BeginPlay()
{
Super::BeginPlay();
// ...
BeginPlaySetup();
}
// Called every frame
void UMover::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
// if (!ObjectRefrence)
// {
// UE_LOG(LogTemp, Error, TEXT("Set ObjectRefrence For Mover Component In Blueprint."));
// return;
// }
// if(ShouldRotate && Rotate)
// {
// RotateObject(DeltaTime);
// }
if(ShouldMove && Move)
{
MoveObject(DeltaTime);
}
}
// void UMover::RotateObject(float DeltaTime) const
// {
// FRotator CurrentRotation = GetOwner()->GetActorRotation();
// FRotator TargetRotation = StartingRotation;
// if(ShouldRotate)
// {
// TargetRotation = StartingRotation + RotateOffset;
// }
// CurrentRotation = FMath::Lerp(CurrentRotation, TargetRotation, DeltaTime * RotateTime);
// GetOwner()->SetActorRotation(CurrentRotation);
// }
void UMover::MoveObject(float DeltaTime) const
{
FVector CurrentVector = GetOwner()->GetActorLocation();
FVector TargetLocation = StartingVector;
if(ShouldMove)
{
TargetLocation = StartingVector + MoveOffset;
}
float Speed = MoveOffset.Length() / MoveTime;
CurrentVector = FMath::VInterpConstantTo(CurrentVector, TargetLocation, DeltaTime, Speed);
GetOwner()->SetActorLocation(CurrentVector);
}
void UMover::SetShouldMove(bool Should)
{
ShouldMove = Should;
}
// void UMover::SetShouldRotate(bool Should)
// {
// ShouldRotate = Should;
// }
void UMover::BeginPlaySetup()
{
StartingVector = GetOwner()->GetActorLocation();
// StartingRotation = GetOwner()->GetActorRotation();
}
SecretWallTriggerComponent.CPP file -
// Fill out your copyright notice in the Description page of Project Settings.
#include "SecretWallTriggerComponent.h"
// Sets default values for this component's properties
USecretWallTriggerComponent::USecretWallTriggerComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void USecretWallTriggerComponent::BeginPlay()
{
Super::BeginPlay();
UE_LOG(LogTemp, Warning, TEXT("Trigger Component Alive."));
}
void USecretWallTriggerComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
AActor* AcceptableActor = GetAcceptableActor();
if (AcceptableActor)
{
AcceptableActor->FindComponentByClass<UPrimitiveComponent>()->SetSimulatePhysics(false);
AcceptableActor->AttachToComponent(this, FAttachmentTransformRules::KeepWorldTransform);
Mover->SetShouldMove(true);
// Mover->SetShouldRotate(true);
UE_LOG(LogTemp, Display, TEXT("Unlocking!"))
}
else
{
Mover->SetShouldMove(false);
// Mover->SetShouldRotate(false);
UE_LOG(LogTemp, Display, TEXT("Locking!"))
}
}
void USecretWallTriggerComponent::ActiveMover(UMover* NewMover)
{
Mover = NewMover;
}
AActor* USecretWallTriggerComponent::GetAcceptableActor()
{
TArray<AActor*> OverlappingActors;
GetOverlappingActors(OverlappingActors);
for (AActor* SingleActor : OverlappingActors)
{
if (SingleActor->ActorHasTag(UnlockTag) && !(SingleActor->ActorHasTag("Grabbed")) )
{
return SingleActor;
}
}
return nullptr;
}
As I press, the play button my unreal engine crashes and gives me the above error. I do not have a single clue why this error keeps showing. This code is from the Crypt Rider Section.