Unreal Engine Crashing ,error: 0xffffffffffffffff

Hey, I was running my game when my game crashed, this is the error-

LoginId:a8fe8e6941b8bdcdd0a4aeb3e6d85804
EpicAccountId:d09d84c33d8c4c7aa27d92101623ada9

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff

UnrealEditor_FirstCppGame_1662!ACPP_PlayerCharacter::CheckInteract() [C:\Users\Divya\OneDrive\Documents\Unreal Projects\TheEvilMannequin\Source\FirstCppGame\CPP_PlayerCharacter.cpp:468]
UnrealEditor_FirstCppGame_1662!TBaseUObjectMethodDelegateInstance<0,ACPP_PlayerCharacter,void __cdecl(void),FDefaultDelegateUserPolicy>::Execute() [D:\EpicGames\UE_5.0\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:594]
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
kernel32
ntdll

This is the code the problem is associated with-

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


#include "CPP_PlayerCharacter.h"
#include "Camera/CameraComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/EngineBaseTypes.h"
#include "Components/CapsuleComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "GameFramework/GameUserSettings.h"
#include "GameFramework/PlayerController.h"
#include "Components/SpotLightComponent.h"
#include "Components/PointLightComponent.h"
#include "Components/AudioComponent.h"
#include "GameFramework/Actor.h"
#include "CPP_Door.h"
#include "Hammer.h"
#include "Wire.h"
#include "PowerBoard.h"
#include "RoomKey.h"
#include "LiftButton.h"
#include "Cupboard0.h"
#include "Lift.h"
#include "LeverHolder.h"
#include "Lever.h"
#include "HealthIncreaser.h"
#include "Components/SkeletalMeshComponent.h"
#include "Components/SceneComponent.h"
#include "Math/Vector2D.h"
#include "Engine/World.h"
#include "InputCoreTypes.h"
#include <iostream>
using namespace std;
// Sets default values
ACPP_PlayerCharacter::ACPP_PlayerCharacter()
{
	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
	FPPCamera = CreateDefaultSubobject<UCameraComponent>("FPPCamera");
	FPPCamera->SetupAttachment(RootComponent);
	Torch = CreateDefaultSubobject<USpotLightComponent>("Torch");
	Torch->SetupAttachment(FPPCamera);
	TorchSwich = CreateDefaultSubobject<UAudioComponent>("TorchClickSound");
	TorchSwich->SetupAttachment(Torch);
	HandMesh = CreateDefaultSubobject<USkeletalMeshComponent>("Hand");
	HandMesh->SetupAttachment(FPPCamera);
	ItemHoldLocation = CreateDefaultSubobject<USceneComponent>("ItemHoldLocation");
	ItemHoldLocation->SetupAttachment(HandMesh);
	PlayerSeeLight = CreateDefaultSubobject<UPointLightComponent>("PointLight");
	PlayerSeeLight->SetupAttachment(RootComponent);
}
// Called when the game starts or when spawned
void ACPP_PlayerCharacter::BeginPlay()
{
	Super::BeginPlay();
	IsDoorInteracted = false;
	CameraTouchYaw = 5;
	CameraTouchPitch = 5;
	IsHoldingRoomKey = false;
	isTouch1 = true;
	subtitle = "I have to defeat her.";
	ItemName = "";
	auto ActivePlayerCameraManager = UGameplayStatics::GetPlayerCameraManager(this, 0);
	ActivePlayerCameraManager->ViewPitchMax = 75;
	ActivePlayerCameraManager->ViewPitchMin = -75;
	DidOnce = false;
	DidOnce2 = false;
	TorchInteracted = false;
	Torch->SetIntensity(70000);
	PlayerSeeLight->SetIntensity(5000);
	PlayerMovementSpeed = 100;
	IsCrouching = false;
	ACPP_PlayerCharacter::MovementComponent = Cast<UCharacterMovementComponent>(GetMovementComponent());
	ACPP_PlayerCharacter::MovementComponent->JumpZVelocity = 400.f;
	TorchOpen = true;
	PlayerStamina = 1.f;
	Interact = false;
	LineTraceSuccessful = false;
	int x = 0;
	HandMesh->SetVisibility(false);
	CheckTouchCrouch = false;
	CheckTouchJump = false;
	HoldingLever = false;
	Range = 400.f;
}

// Called every frame
void ACPP_PlayerCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if (IsHoldingHammer)
	{
		Hammer->SetActorLocation(ItemHoldLocation->GetComponentLocation());
		Hammer->SetActorRotation(ItemHoldLocation->GetComponentRotation());
	}
	if(TorchInteracted)
	{
		OnTorch();
	}
	TorchInteracted = false;
	if(CheckTouchCrouch)
	{
		PlayerCrouch();
	}
	CheckTouchCrouch = false;
	if(CheckTouchJump)
	{
		CheckJump();
	}
	CheckTouchJump = false;
	if (CollectedWires >= 9)
	{
		//subtitle = "I have collected now I have to install them in the right place.";
	}
	if (!IsTouched)
	{
		DidOnce = false;
	}
	if (IsDoorInteracted)
	{
		Doorr->IsInteracting = Interact;
	}
	if (CanDrop)
	{
		if (IsHoldingHammer)
		{
			Hammer->SimulatePhysics(true);
			IsHoldingHammer = false;
		}
		if (IsHoldingRoomKey)
		{
			RoomKey->SimulatePhysics(true);
			IsHoldingRoomKey = false;
		}
		if (IsHoldingLever)
		{
			Lever->SetActorScale3D(FVector(1, 1, 1));
			Lever->SimulatePhysics(true);
			IsHoldingLever = false;
		}
		CanDrop = false;
	}
	FTimerHandle TimerHandle;
	GetWorldTimerManager().SetTimer(TimerHandle, this, &ACPP_PlayerCharacter::CheckInteract, 0.1f, true, 0.0);
}

// Called to bind functionality to input
void ACPP_PlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);
	PlayerInputComponent->BindAxis(TEXT("VerticalMovement"), this, &ACPP_PlayerCharacter::MoveVertically);
	PlayerInputComponent->BindAxis(TEXT("HorizontalMovement"), this, &ACPP_PlayerCharacter::MoveHorizontally);
	PlayerInputComponent->BindAxis(TEXT("Turn"), this, &ACPP_PlayerCharacter::CameraTurn);
	PlayerInputComponent->BindAxis(TEXT("LookUp"), this, &ACPP_PlayerCharacter::CameraLookUp);
	PlayerInputComponent->BindAction(TEXT("Sprint"), IE_Pressed, this, &ACPP_PlayerCharacter::Sprint);
	PlayerInputComponent->BindAction(TEXT("Sprint"), IE_Released, this, &ACPP_PlayerCharacter::Walk);
	PlayerInputComponent->BindAction(TEXT("Crouch"), IE_Pressed, this, &ACPP_PlayerCharacter::PlayerCrouch);
	PlayerInputComponent->BindAction(TEXT("Jump"), IE_Pressed, this, &ACPP_PlayerCharacter::CheckJump);
	PlayerInputComponent->BindAction(TEXT("ToggleTorch"), IE_Pressed, this, &ACPP_PlayerCharacter::ToggleTorch);
	PlayerInputComponent->BindAction(TEXT("Interact"), IE_Pressed, this, &ACPP_PlayerCharacter::PressInteract);
	PlayerInputComponent->BindAction(TEXT("Interact"), IE_Released, this, &ACPP_PlayerCharacter::ReleaseInteract);
	PlayerInputComponent->BindAction(TEXT("Drop"), IE_Pressed, this, &ACPP_PlayerCharacter::OnDrop);
	PlayerInputComponent->BindTouch(IE_Released, this, &ACPP_PlayerCharacter::OnTouchEnd);
}

void ACPP_PlayerCharacter::CheckInteract()
{
	FVector HitEnd = FPPCamera->GetComponentLocation() + FPPCamera->GetForwardVector() * Range;
	GetWorld()->LineTraceSingleByChannel(Hit, FPPCamera->GetComponentLocation(), HitEnd, ECC_Visibility);
	if (Hit.GetActor())
	{
		if (Hit.GetActor()->GetClass()->IsChildOf(ACPP_Door::StaticClass()) == true)
		{
			RaycastHittingTheDoor = true;
			IsDoorInteracted = true;
			Doorr = Cast<ACPP_Door>(Hit.GetActor());
			LineTraceSuccessful = true;
			ItemName = "Door";
			Doorr->IsInteracting = Interact;
			if (Interact)
			{
				if (Doorr->bOpen == true)
				{
					Doorr->bCanOpen = true;
					Doorr->OpenOrClose = false;
				}
				else if (Doorr->bOpen == false)
				{
					Doorr->bCanOpen = true;
					Doorr->OpenOrClose = true;
				}
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(AHealthIncreaser::StaticClass()))
		{
			Food = Cast<AHealthIncreaser>(Hit.GetActor());
			Cast<UPrimitiveComponent>(Food->Mesh)->SetRenderCustomDepth(true);
			LineTraceSuccessful = true;
			ItemName = "Food";
			if (Interact)
			{
				Food->IncreaseStaminaOnRaycast(Food, this);
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(AHammer::StaticClass()))
		{
			Hammer = Cast<AHammer>(Hit.GetActor());
			Cast<UPrimitiveComponent>(Hammer->Mesh)->SetRenderCustomDepth(true);
			LineTraceSuccessful = true;
			ItemName = "Item";
			if (Interact)
			{
				if (IsHoldingRoomKey)
				{
					RoomKey->SimulatePhysics(true);
					IsHoldingRoomKey = false;
				}
				else if (IsHoldingLever)
				{
					Lever->SimulatePhysics(true);
					IsHoldingLever = false;
				}
				Hammer->SetActorLocation(ItemHoldLocation->GetComponentLocation());
				Hammer->SetActorRotation(ItemHoldLocation->GetComponentRotation());
				IsHoldingHammer = true;
				Hammer->SimulatePhysics(false);
				HandMesh->SetVisibility(false);
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(AWire::StaticClass()))
		{
			Wire = Cast<AWire>(Hit.GetActor());
			LineTraceSuccessful = true;
			ItemName = "Wire";
			Cast<UPrimitiveComponent>(Wire->WireMesh)->SetRenderCustomDepth(true);
			if (Interact)
			{
				Wire->WireCollected(this);
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(ALiftButton::StaticClass()))
		{
			LineTraceSuccessful = true;
			IsLiftButtonInteracted = true;
			ItemName = "LiftButton";
			if (Interact)
			{
				auto Button = Cast<ALiftButton>(Hit.GetActor());
				if (Button->bUpper)
				{
					LiftOpen = false;
				}
				else if(!Button->bUpper)
				{
					LiftOpen = true;
				}
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(ARoomKey::StaticClass()))
		{
			RoomKey = Cast<ARoomKey>(Hit.GetActor());
			LineTraceSuccessful = true;
			ItemName = "RoomKey";
			Cast<UPrimitiveComponent>(RoomKey->KeyMesh)->SetRenderCustomDepth(true);
			if (Interact)
			{
				if (IsHoldingHammer)
				{
					Hammer->SimulatePhysics(true);
					IsHoldingHammer = false;
				}
				else if (IsHoldingLever)
				{
					Lever->SimulatePhysics(true);
					IsHoldingLever = false;
				}
				RoomKey->SetActorLocation(ItemHoldLocation->GetComponentLocation());
				RoomKey->SetActorRotation(FRotator(ItemHoldLocation->GetComponentRotation().Pitch, ItemHoldLocation->GetComponentRotation().Yaw, ItemHoldLocation->GetComponentRotation().Roll + 90));
				IsHoldingRoomKey = true;
				HandMesh->SetVisibility(false);
				RoomKey->SimulatePhysics(false);
			}

		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(ACupboard0::StaticClass()))
		{
			auto Cupboard0 = Cast<ACupboard0>(Hit.GetActor());
			LineTraceSuccessful = true;
			ItemName = "Cupboard";
			if (Interact)
			{
				if (Cupboard0->bOpen == true)
				{
					Cupboard0->bCanOpen = true;
					Cupboard0->OpenOrClose = false;
				}
				else if (Doorr->bOpen == false)
				{
					Cupboard0->bCanOpen = true;
					Cupboard0->OpenOrClose = true;
				}
			}
        }
		else if (Hit.GetActor()->GetClass()->IsChildOf(APowerBoard::StaticClass()))
		{
			auto Board = Cast<APowerBoard>(Hit.GetActor());
			LineTraceSuccessful = true;
			if (Interact)
			{
				if (CollectedWires >= 9)
				{ 
					if (Holder)
					{
						if (Holder->LeverAttached && Holder->LeverEnabled)
						{
							Board->RevealWires(true);
						}
					}
				}
				else if (CollectedWires != 8)
				{
					subtitle = "I need more Wires..."; 
				}
				if (Holder == nullptr && CollectedWires == 8)
				{
					subtitle = "There is still something missing.";
				}
				else if(Holder != nullptr && !Holder->LeverAttached && !Holder->LeverEnabled && CollectedWires == 8)
				{
					subtitle = "There is still something missing.";
				}
				else if (Holder != nullptr && Holder->LeverAttached && !Holder->LeverEnabled && CollectedWires == 8)
				{
					subtitle = "I need to enable the lever.";
				}
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(ALeverHolder::StaticClass()))
		{
			Holder = Cast<ALeverHolder>(Hit.GetActor());
			if (!Holder->LeverAttached && !Holder->LeverEnabled)
			{
				LineTraceSuccessful = true;
			}
			if (!Holder->LeverAttached)
			{
				Cast<UPrimitiveComponent>(Holder->Holder)->SetRenderCustomDepth(true);
			}
			else if (Holder->LeverAttached && Holder->LeverEnabled)
			{
				Cast<UPrimitiveComponent>(Holder->Holder)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Holder->LeverBody)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Holder->LeverHolder)->SetRenderCustomDepth(false);
			}
			else
			{
				Cast<UPrimitiveComponent>(Holder->LeverBody)->SetRenderCustomDepth(true);
				Cast<UPrimitiveComponent>(Holder->LeverHolder)->SetRenderCustomDepth(true);
			}
			if (Interact && IsHoldingLever)
			{
				Holder->RevealLever();
				Lever->Destroy();
				IsHoldingLever = false;
				Cast<UPrimitiveComponent>(Holder->Holder)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Holder->LeverBody)->SetRenderCustomDepth(true);
				Cast<UPrimitiveComponent>(Holder->LeverHolder)->SetRenderCustomDepth(true);
			}
			else if (Interact && Holder->LeverAttached)
			{
				Holder->EnableLever();
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(ALever::StaticClass()))
		{
			Lever = Cast<ALever>(Hit.GetActor());
			LineTraceSuccessful = true;
			Cast<UPrimitiveComponent>(Lever->LeverHolder)->SetRenderCustomDepth(true);
			Cast<UPrimitiveComponent>(Lever->LeverBody)->SetRenderCustomDepth(true);
			if (Interact)
			{
				if (IsHoldingHammer)
				{
					Hammer->SimulatePhysics(true);
					IsHoldingHammer = false;
				}
				else if (IsHoldingRoomKey)
				{
					RoomKey->SimulatePhysics(true);
					IsHoldingRoomKey = false;
				}
				Lever->SetActorLocation(ItemHoldLocation->GetComponentLocation());
				Lever->SetActorRotation(FRotator(ItemHoldLocation->GetComponentRotation().Pitch, ItemHoldLocation->GetComponentRotation().Yaw, ItemHoldLocation->GetComponentRotation().Roll + -180));
				IsHoldingLever = true;
				Lever->SimulatePhysics(false);
				HandMesh->SetVisibility(false);
			}
		}
		else
		{
			LineTraceSuccessful = false;
			ItemName = "";
			RaycastHittingTheDoor = false;
			IsLiftButtonInteracted = false;
			if (Food)
			{
				Cast<UPrimitiveComponent>(Food->Mesh)->SetRenderCustomDepth(false);
			}
			if (Hammer)
			{
				Cast<UPrimitiveComponent>(Hammer->Mesh)->SetRenderCustomDepth(false);
			}
			if (RoomKey)
			{
				Cast<UPrimitiveComponent>(RoomKey->KeyMesh)->SetRenderCustomDepth(false);
			}
			if (Wire)
			{
				Cast<UPrimitiveComponent>(Wire->WireMesh)->SetRenderCustomDepth(false);
			}
			if (Holder)
			{
				Cast<UPrimitiveComponent>(Holder->Holder)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Holder->LeverBody)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Holder->LeverHolder)->SetRenderCustomDepth(false);
			}
			if (Lever)
			{
				Cast<UPrimitiveComponent>(Lever->LeverHolder)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Lever->LeverBody)->SetRenderCustomDepth(false);
			}
		}
	}
	else
	{
		LineTraceSuccessful = false;
		ItemName = "";
		RaycastHittingTheDoor = false;
		IsLiftButtonInteracted = false;
		if (Food)
		{
			Cast<UPrimitiveComponent>(Food->Mesh)->SetRenderCustomDepth(false);
		}
		if (Hammer)
		{
			Cast<UPrimitiveComponent>(Hammer->Mesh)->SetRenderCustomDepth(false);
		}
		if (RoomKey)
		{
			Cast<UPrimitiveComponent>(RoomKey->KeyMesh)->SetRenderCustomDepth(false);
		}
		if (Wire)
		{
			Cast<UPrimitiveComponent>(Wire->WireMesh)->SetRenderCustomDepth(false);
		}
		if (Holder)
		{
			Cast<UPrimitiveComponent>(Holder->Holder)->SetRenderCustomDepth(false);
			Cast<UPrimitiveComponent>(Holder->LeverBody)->SetRenderCustomDepth(false);
			Cast<UPrimitiveComponent>(Holder->LeverHolder)->SetRenderCustomDepth(false);
		}
		if (Lever)
		{
			Cast<UPrimitiveComponent>(Lever->LeverHolder)->SetRenderCustomDepth(false);
			Cast<UPrimitiveComponent>(Lever->LeverBody)->SetRenderCustomDepth(false);
		}
	}
}


void ACPP_PlayerCharacter::OnDrop()
{
	CanDrop = true;
}

void ACPP_PlayerCharacter::OnTouchEnd(ETouchIndex::Type TouchType, FVector TouchLocation)
{
	DidOnce = false;
}

void ACPP_PlayerCharacter::OnTouchBegin(ETouchIndex::Type TouchType, FVector TouchLocation)
{
	if (TouchType == ETouchIndex::Touch1)
	{
		isTouch1 = true;
	}
	else
	{
		isTouch1 = false;
	}
}

void ACPP_PlayerCharacter::GetTouch(float DeltaTime, ETouchIndex::Type TouchType)
{
	FVector2D TouchLocation;
	APlayerController* ActivePlayerController = GetController<APlayerController>();
	ActivePlayerController->GetInputTouchState(TouchType, TouchLocation.X, TouchLocation.Y, IsTouched);
	if (!DidOnce)
	{
		ActivePlayerController->GetInputTouchState(TouchType, PrevX, PrevY, IsTouched);
		DidOnce = true;
	}
	ActivePlayerController->GetInputTouchState(TouchType, X, Y, IsTouched);
	float FinalRotYaw = (X - PrevX) * DeltaTime * CameraTouchYaw;
	float FinalRotPitch = (Y - PrevY) * DeltaTime * CameraTouchPitch;
	AddControllerYawInput(FinalRotYaw);
	AddControllerPitchInput(FinalRotPitch);
	ActivePlayerController->GetInputTouchState(TouchType, PrevX, PrevY, IsTouched);
}

bool ACPP_PlayerCharacter::IsTouchMoved()
{
	APlayerController* ActivePlayerController = UGameplayStatics::GetPlayerController(this, 0);
	if (!DidOnce2)
	{
		ActivePlayerController->GetInputTouchState(ETouchIndex::Touch1, PrevTouchMoved.X, PrevTouchMoved.Y, TouchP);
		DidOnce2 = true;
	}
	ActivePlayerController->GetInputTouchState(ETouchIndex::Touch1, CurrTouchMoved.X, CurrTouchMoved.Y, TouchP);
	CurrTouchMoved.X = (int32)CurrTouchMoved.X;
	CurrTouchMoved.Y = (int32)CurrTouchMoved.Y;
	if (CurrTouchMoved != PrevTouchMoved)
	{
		TouchMoved = true;
	}
	else if (CurrTouchMoved == PrevTouchMoved)
	{
		TouchMoved = false;
	}
	ActivePlayerController->GetInputTouchState(ETouchIndex::Touch1, PrevTouchMoved.X, PrevTouchMoved.Y, TouchP);
	PrevTouchMoved.X = (int32)PrevTouchMoved.X;
	PrevTouchMoved.Y = (int32)PrevTouchMoved.Y;
	return TouchMoved;
	//Finally Done!!
}

void ACPP_PlayerCharacter::ReflexAction(FText Action)
{

}

void ACPP_PlayerCharacter::PressInteract()
{
	Interact = true;
}

void ACPP_PlayerCharacter::ReleaseInteract()
{
	Interact = false;
}

void ACPP_PlayerCharacter::ToggleTorch()
{
	TorchInteracted = true;
}

void ACPP_PlayerCharacter::OnTorch()
{
	if(TorchOpen == false)
	{
		if (TorchSwich)
		{
			TorchSwich->Play();
		}
		Torch->SetIntensity(70000);
		PlayerSeeLight->SetIntensity(5000);
		TorchOpen = true;
	}
	else
	{
		if (TorchSwich)
		{
			TorchSwich->Play();
		}
		Torch->SetIntensity(0);
		PlayerSeeLight->SetIntensity(3000);
		TorchOpen = false;
	}
}

void ACPP_PlayerCharacter::CheckJump()
{
	ACharacter::Jump();
}

void ACPP_PlayerCharacter::MoveVertically(float Value)
{
	if (Value)
	{
		AddMovementInput(GetActorForwardVector(), Value * UGameplayStatics::GetWorldDeltaSeconds(this) * PlayerMovementSpeed);
	}
}

void ACPP_PlayerCharacter::MoveHorizontally(float Value)
{
	if (Value)
	{
		AddMovementInput(GetActorRightVector(), Value * UGameplayStatics::GetWorldDeltaSeconds(this) * PlayerMovementSpeed);
	}
}

void ACPP_PlayerCharacter::Walk()
{
	if (!IsCrouching)
	{
		PlayerMovementSpeed = 100;
		ACPP_PlayerCharacter::MovementComponent->JumpZVelocity = 400;
	}
	else
	{
		return;
	}
}

void ACPP_PlayerCharacter::Sprint()
{
	if (!IsCrouching)
	{
		PlayerMovementSpeed = 200;
		ACPP_PlayerCharacter::MovementComponent->JumpZVelocity = 600;
	}
	else
	{
		return;
	}
}

void ACPP_PlayerCharacter::CameraTurn(float Value)
{
	if (Value)
	{
		float FinalRot = Value * PlayerCameraSensitivityYaw * UGameplayStatics::GetWorldDeltaSeconds(this);
		AddControllerYawInput(FinalRot);
	}
}

void ACPP_PlayerCharacter::CameraLookUp(float Value)
{
	if (Value)
	{
		float FinalRot = Value * -PlayerCameraSensitivityPitch * UGameplayStatics::GetWorldDeltaSeconds(this);
		AddControllerPitchInput(FinalRot);
	}
}

void ACPP_PlayerCharacter::PlayerCrouch()
{
	if (IsCrouching == false)
	{
		UCapsuleComponent* CapsuleComponentt = GetCapsuleComponent();
		CapsuleComponentt->SetCapsuleHalfHeight(100.f);
		FPPCamera->SetRelativeLocation(FVector(0.f, 0.f, 60.f));
		IsCrouching = true;
		PlayerMovementSpeed = 50;
		ACPP_PlayerCharacter::MovementComponent->JumpZVelocity = 0;
	}
	else
	{
		UCapsuleComponent* CapsuleComponentt = GetCapsuleComponent();
		CapsuleComponentt->SetCapsuleHalfHeight(140.f);
		FPPCamera->SetRelativeLocation(FVector(0.f, 0.f, 100.f));
		IsCrouching = false;
		PlayerMovementSpeed = 100;
		ACPP_PlayerCharacter::MovementComponent->JumpZVelocity = 400;
	}
}

This error occured when I spawned some actors from the gamemode in blueprints when the game starts.
Also, when the raycast hits anything(the player sends raycast every tick, and when the raycast hits any object, the function goes into many if statements this causes a little bit of lag when the raycast is hitted to something, so I guess the problem is somewhat associated with this raycast, because, until the player has hitted any object the game works fine like usual).
Can anyone please help me?

Hello Divyanshu, can you tell us what’s on line 468?

The function CheckInteract() ends on that line.
i.e.

void ACPP_PlayerCharacter::CheckInteract()
{
	FVector HitEnd = FPPCamera->GetComponentLocation() + FPPCamera->GetForwardVector() * Range;
	GetWorld()->LineTraceSingleByChannel(Hit, FPPCamera->GetComponentLocation(), HitEnd, ECC_Visibility);
	if (Hit.GetActor())
	{
		if (Hit.GetActor()->GetClass()->IsChildOf(ACPP_Door::StaticClass()) == true)
		{
			RaycastHittingTheDoor = true;
			IsDoorInteracted = true;
			Doorr = Cast<ACPP_Door>(Hit.GetActor());
			LineTraceSuccessful = true;
			ItemName = "Door";
			Doorr->IsInteracting = Interact;
			if (Interact)
			{
				if (Doorr->bOpen == true)
				{
					Doorr->bCanOpen = true;
					Doorr->OpenOrClose = false;
				}
				else if (Doorr->bOpen == false)
				{
					Doorr->bCanOpen = true;
					Doorr->OpenOrClose = true;
				}
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(AHealthIncreaser::StaticClass()))
		{
			Food = Cast<AHealthIncreaser>(Hit.GetActor());
			Cast<UPrimitiveComponent>(Food->Mesh)->SetRenderCustomDepth(true);
			LineTraceSuccessful = true;
			ItemName = "Food";
			if (Interact)
			{
				Food->IncreaseStaminaOnRaycast(Food, this);
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(AHammer::StaticClass()))
		{
			Hammer = Cast<AHammer>(Hit.GetActor());
			Cast<UPrimitiveComponent>(Hammer->Mesh)->SetRenderCustomDepth(true);
			LineTraceSuccessful = true;
			ItemName = "Item";
			if (Interact)
			{
				if (IsHoldingRoomKey)
				{
					RoomKey->SimulatePhysics(true);
					IsHoldingRoomKey = false;
				}
				else if (IsHoldingLever)
				{
					Lever->SimulatePhysics(true);
					IsHoldingLever = false;
				}
				Hammer->SetActorLocation(ItemHoldLocation->GetComponentLocation());
				Hammer->SetActorRotation(ItemHoldLocation->GetComponentRotation());
				IsHoldingHammer = true;
				Hammer->SimulatePhysics(false);
				HandMesh->SetVisibility(false);
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(AWire::StaticClass()))
		{
			Wire = Cast<AWire>(Hit.GetActor());
			LineTraceSuccessful = true;
			ItemName = "Wire";
			Cast<UPrimitiveComponent>(Wire->WireMesh)->SetRenderCustomDepth(true);
			if (Interact)
			{
				Wire->WireCollected(this);
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(ALiftButton::StaticClass()))
		{
			LineTraceSuccessful = true;
			IsLiftButtonInteracted = true;
			ItemName = "LiftButton";
			if (Interact)
			{
				auto Button = Cast<ALiftButton>(Hit.GetActor());
				if (Button->bUpper)
				{
					LiftOpen = false;
				}
				else if(!Button->bUpper)
				{
					LiftOpen = true;
				}
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(ARoomKey::StaticClass()))
		{
			RoomKey = Cast<ARoomKey>(Hit.GetActor());
			LineTraceSuccessful = true;
			ItemName = "RoomKey";
			Cast<UPrimitiveComponent>(RoomKey->KeyMesh)->SetRenderCustomDepth(true);
			if (Interact)
			{
				if (IsHoldingHammer)
				{
					Hammer->SimulatePhysics(true);
					IsHoldingHammer = false;
				}
				else if (IsHoldingLever)
				{
					Lever->SimulatePhysics(true);
					IsHoldingLever = false;
				}
				RoomKey->SetActorLocation(ItemHoldLocation->GetComponentLocation());
				RoomKey->SetActorRotation(FRotator(ItemHoldLocation->GetComponentRotation().Pitch, ItemHoldLocation->GetComponentRotation().Yaw, ItemHoldLocation->GetComponentRotation().Roll + 90));
				IsHoldingRoomKey = true;
				HandMesh->SetVisibility(false);
				RoomKey->SimulatePhysics(false);
			}

		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(ACupboard0::StaticClass()))
		{
			auto Cupboard0 = Cast<ACupboard0>(Hit.GetActor());
			LineTraceSuccessful = true;
			ItemName = "Cupboard";
			if (Interact)
			{
				if (Cupboard0->bOpen == true)
				{
					Cupboard0->bCanOpen = true;
					Cupboard0->OpenOrClose = false;
				}
				else if (Doorr->bOpen == false)
				{
					Cupboard0->bCanOpen = true;
					Cupboard0->OpenOrClose = true;
				}
			}
        }
		else if (Hit.GetActor()->GetClass()->IsChildOf(APowerBoard::StaticClass()))
		{
			auto Board = Cast<APowerBoard>(Hit.GetActor());
			LineTraceSuccessful = true;
			if (Interact)
			{
				if (CollectedWires >= 9)
				{ 
					if (Holder)
					{
						if (Holder->LeverAttached && Holder->LeverEnabled)
						{
							Board->RevealWires(true);
						}
					}
				}
				else if (CollectedWires != 8)
				{
					subtitle = "I need more Wires..."; 
				}
				if (Holder == nullptr && CollectedWires == 8)
				{
					subtitle = "There is still something missing.";
				}
				else if(Holder != nullptr && !Holder->LeverAttached && !Holder->LeverEnabled && CollectedWires == 8)
				{
					subtitle = "There is still something missing.";
				}
				else if (Holder != nullptr && Holder->LeverAttached && !Holder->LeverEnabled && CollectedWires == 8)
				{
					subtitle = "I need to enable the lever.";
				}
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(ALeverHolder::StaticClass()))
		{
			Holder = Cast<ALeverHolder>(Hit.GetActor());
			if (!Holder->LeverAttached && !Holder->LeverEnabled)
			{
				LineTraceSuccessful = true;
			}
			if (!Holder->LeverAttached)
			{
				Cast<UPrimitiveComponent>(Holder->Holder)->SetRenderCustomDepth(true);
			}
			else if (Holder->LeverAttached && Holder->LeverEnabled)
			{
				Cast<UPrimitiveComponent>(Holder->Holder)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Holder->LeverBody)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Holder->LeverHolder)->SetRenderCustomDepth(false);
			}
			else
			{
				Cast<UPrimitiveComponent>(Holder->LeverBody)->SetRenderCustomDepth(true);
				Cast<UPrimitiveComponent>(Holder->LeverHolder)->SetRenderCustomDepth(true);
			}
			if (Interact && IsHoldingLever)
			{
				Holder->RevealLever();
				Lever->Destroy();
				IsHoldingLever = false;
				Cast<UPrimitiveComponent>(Holder->Holder)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Holder->LeverBody)->SetRenderCustomDepth(true);
				Cast<UPrimitiveComponent>(Holder->LeverHolder)->SetRenderCustomDepth(true);
			}
			else if (Interact && Holder->LeverAttached)
			{
				Holder->EnableLever();
			}
		}
		else if (Hit.GetActor()->GetClass()->IsChildOf(ALever::StaticClass()))
		{
			Lever = Cast<ALever>(Hit.GetActor());
			LineTraceSuccessful = true;
			Cast<UPrimitiveComponent>(Lever->LeverHolder)->SetRenderCustomDepth(true);
			Cast<UPrimitiveComponent>(Lever->LeverBody)->SetRenderCustomDepth(true);
			if (Interact)
			{
				if (IsHoldingHammer)
				{
					Hammer->SimulatePhysics(true);
					IsHoldingHammer = false;
				}
				else if (IsHoldingRoomKey)
				{
					RoomKey->SimulatePhysics(true);
					IsHoldingRoomKey = false;
				}
				Lever->SetActorLocation(ItemHoldLocation->GetComponentLocation());
				Lever->SetActorRotation(FRotator(ItemHoldLocation->GetComponentRotation().Pitch, ItemHoldLocation->GetComponentRotation().Yaw, ItemHoldLocation->GetComponentRotation().Roll + -180));
				IsHoldingLever = true;
				Lever->SimulatePhysics(false);
				HandMesh->SetVisibility(false);
			}
		}
		else
		{
			LineTraceSuccessful = false;
			ItemName = "";
			RaycastHittingTheDoor = false;
			IsLiftButtonInteracted = false;
			if (Food)
			{
				Cast<UPrimitiveComponent>(Food->Mesh)->SetRenderCustomDepth(false);
			}
			if (Hammer)
			{
				Cast<UPrimitiveComponent>(Hammer->Mesh)->SetRenderCustomDepth(false);
			}
			if (RoomKey)
			{
				Cast<UPrimitiveComponent>(RoomKey->KeyMesh)->SetRenderCustomDepth(false);
			}
			if (Wire)
			{
				Cast<UPrimitiveComponent>(Wire->WireMesh)->SetRenderCustomDepth(false);
			}
			if (Holder)
			{
				Cast<UPrimitiveComponent>(Holder->Holder)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Holder->LeverBody)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Holder->LeverHolder)->SetRenderCustomDepth(false);
			}
			if (Lever)
			{
				Cast<UPrimitiveComponent>(Lever->LeverHolder)->SetRenderCustomDepth(false);
				Cast<UPrimitiveComponent>(Lever->LeverBody)->SetRenderCustomDepth(false);
			}
		}
	}
	else
	{
		LineTraceSuccessful = false;
		ItemName = "";
		RaycastHittingTheDoor = false;
		IsLiftButtonInteracted = false;
		if (Food)
		{
			Cast<UPrimitiveComponent>(Food->Mesh)->SetRenderCustomDepth(false);
		}
		if (Hammer)
		{
			Cast<UPrimitiveComponent>(Hammer->Mesh)->SetRenderCustomDepth(false);
		}
		if (RoomKey)
		{
			Cast<UPrimitiveComponent>(RoomKey->KeyMesh)->SetRenderCustomDepth(false);
		}
		if (Wire)
		{
			Cast<UPrimitiveComponent>(Wire->WireMesh)->SetRenderCustomDepth(false);
		}
		if (Holder)
		{
			Cast<UPrimitiveComponent>(Holder->Holder)->SetRenderCustomDepth(false);
			Cast<UPrimitiveComponent>(Holder->LeverBody)->SetRenderCustomDepth(false);
			Cast<UPrimitiveComponent>(Holder->LeverHolder)->SetRenderCustomDepth(false);
		}
		if (Lever)
		{
			Cast<UPrimitiveComponent>(Lever->LeverHolder)->SetRenderCustomDepth(false);
			Cast<UPrimitiveComponent>(Lever->LeverBody)->SetRenderCustomDepth(false);
		}
	}
}//ThisLine is line 468

And also when I stop spawing the objects from the bp the problem go away(I spawn 8 wire actors using for each loop on the begin play).
This is the image of the blueprint that causes this problem-


Please help me to solve this problem I want to release this game as soon as possible.

1 Like

Where is your Array variable?

I use 4 array and choose one random array and give that value to that final array variable. This code is executed in the game mode of my game.
This is the code-

int WireVectorNum = FMath::RandRange(1, 4);
	if (WireVectorNum <= 4 && WireVectorNum >= 1)
	{
		if (WireVectorNum == 1)
		{
			FinalWireVector = WiresSpawnLocation1;
		}
		else if (WireVectorNum == 2)
		{
			FinalWireVector = WiresSpawnLocation2;
		}
		else if (WireVectorNum == 3)
		{
			FinalWireVector = WiresSpawnLocation3;
		}
		else
		{
			FinalWireVector = WiresSpawnLocation4;
		}
	}

It is possible to see your WiresSpawnLocation1 to 4 variables

I didn’t understood what you wanted to say, they are given value in the bp file of the game mode.

I’m trying to determine where the code that generates the error is. But seeing only a part of your code it’s quite complicated.

So, what do you want?

Shall I give you the game mode bp file?

The gm bp file-
BP_GM_TheEvilMannequinDefault.uasset (161.0 KB)

Can you enable symbols for debugging, as explained in this post?

I don’t know how to enable symbols.

You just have to follow the link I put to you and read.

Ok

After that?

Relaunch your project and now look at the mistake you made.

How, do I have to crash the project again?

Here maybe ?

I mean how to use this?