i’m trying to cast my aicharacter to hit.getactor but i keep getting this error identifier “Hit” is undefined and for my if statment if my hit.getactor is true then i can apply damage (damageamount) and i get the same error and i’m apply damage to my linetrace
HordeCharacter.cpp
void AHordeCharacter::OnFire()
{
AAI_Character* character = Cast<AAI_Character>(Hit.GetActor);
FHitResult Hit(ForceInit);
FVector start = FP_Gun->GetForwardVector();
FVector End = start + (FP_Gun->GetForwardVector()* 700.f);
FCollisionQueryParams CollisionParams;
FVector Start = FP_Gun->GetComponentLocation();
DrawDebugLine(GetWorld(), Start, End, FColor::Green, true, 2.f, false, 4.f);
GetWorld()->LineTraceSingleByChannel(Hit, start, End, ECC_WorldDynamic, CollisionParams);
if (Hit.GetActor)
{
character->damage(damageamount);
}
}
AI character.h
health = 5.f;
damageamount = 2.f;
void AAI_Character::damage(float damageamount)
{
health = health - damageamount;
}