Update AI for Hit Location Damage, Dynamic Crosshair & Hit Markers

This commit is contained in:
Philip W 2024-03-15 10:45:11 +00:00
parent d7a0ffbbec
commit 7ae5c1f349
16 changed files with 60 additions and 18 deletions

View File

@ -40,6 +40,7 @@
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Projectile") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Projectile")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Waypoint") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Waypoint")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Ignore,bTraceType=False,bStaticObject=False,Name="Player") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Ignore,bTraceType=False,bStaticObject=False,Name="Player")
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel4,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Enemy")
+EditProfiles=(Name="Trigger",CustomResponses=((Channel="Projectile",Response=ECR_Ignore))) +EditProfiles=(Name="Trigger",CustomResponses=((Channel="Projectile",Response=ECR_Ignore)))
-ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall") -ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall")
-ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn") -ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn")

BIN
EndlessVendetta/Content/Assets/Crosshair/Crosshair.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
EndlessVendetta/Content/Assets/Crosshair/CrosshairDot.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
EndlessVendetta/Content/Levels/AITest.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -12,6 +12,7 @@ AAI_RestrictedZone::AAI_RestrictedZone()
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. // 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; PrimaryActorTick.bCanEverTick = true;
BoxCollision = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxCollision")); BoxCollision = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxCollision"));
BoxCollision->SetCollisionResponseToChannel(ECC_EngineTraceChannel4, ECR_Overlap);
} }
// Called when the game starts or when spawned // Called when the game starts or when spawned

View File

@ -70,6 +70,11 @@ void AEndlessVendettaCharacter::SetOverlayState(const EOverlayState OverlayState
SetOverlayStateEvent.Broadcast(OverlayState); SetOverlayStateEvent.Broadcast(OverlayState);
} }
void AEndlessVendettaCharacter::SuccessfulHit(const bool bIsHeadshot) const
{
SuccessfulHitEvent.Broadcast(bIsHeadshot);
}
void AEndlessVendettaCharacter::BeginPlay() void AEndlessVendettaCharacter::BeginPlay()
{ {
// Call the base class // Call the base class

View File

@ -171,6 +171,13 @@ public:
UPROPERTY(BlueprintAssignable, Category = "Restricted Area") UPROPERTY(BlueprintAssignable, Category = "Restricted Area")
FRestrictedAreaStatusChangedSignature RestrictedAreaStatusChanged; FRestrictedAreaStatusChangedSignature RestrictedAreaStatusChanged;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSuccessfulHitEvent, bool, bIsHeadshot);
UPROPERTY(BlueprintAssignable, Category = "Weapons")
FSuccessfulHitEvent SuccessfulHitEvent;
void SuccessfulHit(bool bIsHeadshot) const;
protected: protected:
virtual void BeginPlay() override; virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override; virtual void Tick(float DeltaTime) override;

View File

@ -179,7 +179,11 @@ void ABaseWeaponClass::Fire()
traceStart = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()))->GetSocketLocation("Muzzle"); traceStart = Cast<USkeletalMeshComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass()))->GetSocketLocation("Muzzle");
traceEnd = traceStart + Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->GetFirstPersonCameraComponent()->GetForwardVector() * BulletDistance; traceEnd = traceStart + Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->GetFirstPersonCameraComponent()->GetForwardVector() * BulletDistance;
if (GetWorldTimerManager().IsTimerActive(timerHandle)) return; if (GetWorldTimerManager().IsTimerActive(timerHandle)) return;
GetWorld()->LineTraceSingleByChannel(outHit, traceStart, traceEnd, ECC_Visibility, collisionParams); FCollisionObjectQueryParams ObjectQueryParams;
ObjectQueryParams.AddObjectTypesToQuery(ECC_Pawn);
ObjectQueryParams.AddObjectTypesToQuery(ECC_WorldStatic);
ObjectQueryParams.AddObjectTypesToQuery(ECC_WorldDynamic);
GetWorld()->LineTraceSingleByObjectType(outHit, traceStart, traceEnd, ObjectQueryParams, collisionParams);
WeaponFired.Broadcast(); WeaponFired.Broadcast();
playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1); playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1);
currentAmmoCount -= 1; currentAmmoCount -= 1;
@ -197,10 +201,25 @@ void ABaseWeaponClass::Fire()
{ {
tempWeaponDamage = WeaponDamage; tempWeaponDamage = WeaponDamage;
} }
if (ATargetDummy* TargetDummy = Cast<ATargetDummy>(outHit.GetActor())) TargetDummy->TargetShot(); if (Cast<AAICharacter>(outHit.GetActor()))
if (!Cast<AAICharacter>(outHit.GetActor())) return; {
if (outHit.BoneName.ToString().ToLower() == "head")
{
tempWeaponDamage *= 2;
endlessVendettaChar->SuccessfulHit(true);
}
else
{
endlessVendettaChar->SuccessfulHit(false);
}
Cast<AAICharacter>(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this); Cast<AAICharacter>(outHit.GetActor())->TakeDamage(tempWeaponDamage, FPointDamageEvent(), GetWorld()->GetFirstPlayerController(), this);
} }
if (ATargetDummy* TargetDummy = Cast<ATargetDummy>(outHit.GetActor()))
{
TargetDummy->TargetShot();
endlessVendettaChar->SuccessfulHit(false);
}
}
HideNeedReloadUI(); HideNeedReloadUI();
} }
else if (currentAmmoCount <= 0) else if (currentAmmoCount <= 0)