when i press play my project crash, i have been using some code from the course to do another videogame but i dont really know how to fix this crash
here is the code where the crash report the errors
// Fill out your copyright notice in the Description page of Project Settings.
#include “Sword.h”
#include “Components/SkeletalMeshComponent.h”
#include “Kismet/GameplayStatics.h”
#include “DrawDebugHelpers.h”
#include “TheLegend.h”
// Sets default values
ASword::ASword()
{
// 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;
}
// Called when the game starts or when spawned
void ASword::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ASword::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ASword::Hitting()
{
FHitResult Hit;
FVector SwordDirection;
bool bSuccess = SwordTraceLine(Hit, SwordDirection);
if(bSuccess)
{
DrawDebugPoint(GetWorld(), Hit.Location, 20, FColor::Red, true);
AActor* HitActor = Hit.GetActor();
if(HitActor != nullptr)
{
FPointDamageEvent DamageEvent( Damage, Hit, SwordDirection, nullptr);
AController* OwnerController = GetOwnerController();
HitActor-> TakeDamage( Damage,DamageEvent, OwnerController, this);
}
//if(Sword -> IsOverlappingActor(Enemy))
//{
//TakeDamage();
//}
}
}
bool ASword::SwordTraceLine(FHitResult &Hit, FVector &SwordDirection)
{
AController* OwnerController = GetOwnerController();
if(OwnerController == nullptr)return(false);
FVector Location;
FRotator Rotation;
OwnerController-> GetPlayerViewPoint(Location, Rotation);
SwordDirection = -Rotation.Vector();
FVector End = Location + Rotation.Vector() * MaxRange;
FCollisionQueryParams Params;
Params.AddIgnoredActor(this);
Params.AddIgnoredActor(GetOwner());
return GetWorld() -> LineTraceSingleByChannel(Hit,Location, End, ECollisionChannel::ECC_GameTraceChannel1, Params);
}
AController* ASword::GetOwnerController() const
{
APawn* OwnerPawn = Cast<APawn>(GetOwner());
if(OwnerPawn == nullptr) return nullptr;
return OwnerPawn -> GetController();
}