Cleaned up & added Weapon kick shake (non-universal)

This commit is contained in:
Marcel Hara 2023-10-04 15:45:43 +01:00
parent c4da037d2d
commit a2035ffe2f
9 changed files with 40 additions and 16 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6c3599c78d84a6895d06de8ce3697a6aefd517ac0105d041cab6f5124090bb3b
size 35834
oid sha256:fc4caf67df37627a19c4b9f2c464d84cb293574db45f018458c0d59e0a15ba1a
size 37750

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:694f084a31b369305b9cf0e066786a624f73721bf819d3823177703341f0b98c
size 28902
oid sha256:77b4872fd2fde68620f3fb539222718cbe2c66160a956c6373d3650c58a9bf88
size 29117

Binary file not shown.

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:69e0dd14f07413220251048a5a7bb322eebd9e2d9362dc29bab3d3de096a9a82
size 29337
oid sha256:668c94fe648e9fde608e3a07b193f42087fddc44d0e76ec3e4705be642f78679
size 29493

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:51fdff374c4c25c321646b9315bc5286b1ddc89511a597538bf96bea96222e02
oid sha256:f9dd9531bbf28069122709420605ec7c6478ddea44b642b28f016b2349a05597
size 5061

View File

@ -2,7 +2,11 @@
#include "BaseWeaponClass.h"
#include "AIHelpers.h"
#include "GeneratedCodeHelpers.h"
#include "EndlessVendetta/EndlessVendettaCharacter.h"
#include "Kismet/KismetMathLibrary.h"
#include "Components/CapsuleComponent.h"
#include "Kismet/GameplayStatics.h"
@ -28,6 +32,11 @@ void ABaseWeaponClass::BeginPlay()
GunStartArrow = Cast<UArrowComponent>(actorComp);
break;
}
if (!playerControllerRef)
{
playerControllerRef = UGameplayStatics::GetPlayerController(GetWorld(), 0);
}
}
@ -35,6 +44,7 @@ void ABaseWeaponClass::BeginPlay()
void ABaseWeaponClass::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ABaseWeaponClass::ClickDetectionTimer()
@ -47,6 +57,7 @@ void ABaseWeaponClass::CancelFire()
GetWorldTimerManager().ClearTimer(timerHandle);
}
void ABaseWeaponClass::Fire()
{
FHitResult outHit;
@ -63,11 +74,12 @@ void ABaseWeaponClass::Fire()
}
GetWorld()->LineTraceSingleByChannel(outHit, traceStart, traceEnd, ECC_Visibility, collisionParams);
//Debug line to see where the trace hit
DrawDebugLine(this->GetWorld(), traceStart, traceEnd, FColor::Red, true, 500.0f, 0U, 5.f);
DrawDebugLine(this->GetWorld(), traceStart, traceEnd, FColor::Red, false, 5.0f, 0U, 2.5f);
playerControllerRef->PlayerCameraManager->StartCameraShake(CameraShakeClass, 1);
ClickDetectionTimer();
if (outHit.bBlockingHit)
{
UE_LOG(LogTemp, Display, TEXT("hit item: %s"), *outHit.GetActor()->GetName());
}
}

View File

@ -5,6 +5,7 @@
#include "CoreMinimal.h"
#include "WeaponItemClass.h"
#include "Components/ArrowComponent.h"
#include "Kismet/KismetMathLibrary.h"
#include "BaseWeaponClass.generated.h"
class AEndlessVendettaCharacter;
@ -43,7 +44,7 @@ public:
UTexture2D* WeaponImage;
UFUNCTION(BlueprintCallable, Category = "Weapons")
void Fire();
virtual void Fire();
UFUNCTION(BlueprintCallable, Category = "Weapons")
void ClickDetectionTimer();
@ -53,10 +54,16 @@ public:
UPROPERTY(VisibleAnywhere)
ACharacter* player;
UPROPERTY()
APlayerController* playerControllerRef;
FTimerHandle timerHandle;
bool bFirstBulletShot = false;
UPROPERTY(EditAnywhere)
TSubclassOf<UCameraShakeBase> CameraShakeClass;
private:
UArrowComponent* GunStartArrow;
@ -64,10 +71,4 @@ private:
UPROPERTY(EditAnywhere)
float BulletDistance;
//Add HoldFire functionality after pistol is complete for holding fire for pistol and make it start spraying innacuratly.
// UFUNCTION(BlueprintCallable, Category = "Weapons")
// void HoldFire();
};

View File

@ -24,3 +24,9 @@ void APistolClass::Tick(float DeltaTime)
Super::Tick(DeltaTime);
}
void APistolClass::Fire()
{
Super::Fire();
UE_LOG(LogTemp, Display, TEXT("Testing overrides: Pistol has been fired"));
}

View File

@ -22,4 +22,6 @@ protected:
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
virtual void Fire() override;
};