Fixed crash + added line trace when shooting
This commit is contained in:
parent
4680eb71ae
commit
6c3072d6f9
BIN
Content/Legumix/BP_GameMode.uasset
(Stored with Git LFS)
BIN
Content/Legumix/BP_GameMode.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Player/BP_Play.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Player/BP_Play.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Player/BP_Player.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/BP_Player.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Weapon/Shotgun/BP_Revolver.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Weapon/Shotgun/BP_Revolver.uasset
(Stored with Git LFS)
Binary file not shown.
@ -60,10 +60,23 @@ void ALMPlayer::PlayAnimation(UAnimMontage* Animation)
|
|||||||
void ALMPlayer::FireBullets(const FLMBulletInfo Settings)
|
void ALMPlayer::FireBullets(const FLMBulletInfo Settings)
|
||||||
{
|
{
|
||||||
FVector EndLocation = Settings.Origin + (Settings.Direction * Settings.MaxDistance);
|
FVector EndLocation = Settings.Origin + (Settings.Direction * Settings.MaxDistance);
|
||||||
TArray<FHitResult> Hits;
|
TArray<FHitResult> Hits = TArray<FHitResult>();
|
||||||
DrawDebugLineTraceMulti(GetWorld(), Settings.Origin, EndLocation, EDrawDebugTrace::ForDuration, true, Hits, FColor::Green, FColor::Red, 10.f);
|
GetWorld()->LineTraceMultiByChannel(Hits, Settings.Origin, EndLocation, ECC_Camera);
|
||||||
|
DrawDebugLineTraceMulti(GetWorld(), Settings.Origin, EndLocation, EDrawDebugTrace::ForDuration, Hits.Num() > 0, Hits, FColor::Green, FColor::Red, 10.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FVector ALMPlayer::GetWeaponFiringOrigin() const
|
||||||
|
{
|
||||||
|
if (!Camera)
|
||||||
|
{
|
||||||
|
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.f, FColor::Silver, TEXT("No camera ???"));
|
||||||
|
return FVector::ZeroVector;
|
||||||
|
}
|
||||||
|
return Camera->GetComponentTransform().GetLocation();
|
||||||
|
}
|
||||||
|
FVector ALMPlayer::GetAimVector() const { return Camera->GetForwardVector(); }
|
||||||
|
|
||||||
|
|
||||||
void ALMPlayer::Tick(float DeltaTime)
|
void ALMPlayer::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
@ -15,7 +15,6 @@ ALMShotgun::ALMShotgun()
|
|||||||
|
|
||||||
void ALMShotgun::PrimaryFire()
|
void ALMShotgun::PrimaryFire()
|
||||||
{
|
{
|
||||||
ALMPlayer* Player = Cast<ALMPlayer>(GetOuter());
|
|
||||||
if (!Player)
|
if (!Player)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "Weapon/LMWeaponBase.h"
|
#include "Weapon/LMWeaponBase.h"
|
||||||
|
|
||||||
#include "Components/AudioComponent.h"
|
#include "Components/AudioComponent.h"
|
||||||
|
#include "Player/LMPlayer.h"
|
||||||
|
|
||||||
|
|
||||||
ALMWeaponBase::ALMWeaponBase()
|
ALMWeaponBase::ALMWeaponBase()
|
||||||
@ -27,6 +28,18 @@ void ALMWeaponBase::BeginPlay()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ALMWeaponBase::Setup(USkeletalMeshComponent* Mesh, AActor* CharOwner)
|
||||||
|
{
|
||||||
|
SetActorHiddenInGame(true);
|
||||||
|
FAttachmentTransformRules Rules = FAttachmentTransformRules(EAttachmentRule::SnapToTarget,
|
||||||
|
EAttachmentRule::KeepRelative,
|
||||||
|
EAttachmentRule::KeepRelative,
|
||||||
|
false);
|
||||||
|
|
||||||
|
AttachToComponent(Mesh, Rules);
|
||||||
|
Player = Cast<ALMPlayer>(CharOwner);
|
||||||
|
}
|
||||||
|
|
||||||
void ALMWeaponBase::Reload()
|
void ALMWeaponBase::Reload()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -27,16 +27,8 @@ void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh)
|
|||||||
|
|
||||||
ALMWeaponBase* Instance = GetWorld()->SpawnActor<ALMWeaponBase>(WeaponTemplate);
|
ALMWeaponBase* Instance = GetWorld()->SpawnActor<ALMWeaponBase>(WeaponTemplate);
|
||||||
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 2.f, FColor::Blue, TEXT("Spawing"));
|
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 2.f, FColor::Blue, TEXT("Spawing"));
|
||||||
Instance->SetActorHiddenInGame(true);
|
Instance->Setup(ArmsMesh, GetOwner());
|
||||||
|
|
||||||
Weapons.Add(Instance);
|
Weapons.Add(Instance);
|
||||||
|
|
||||||
FAttachmentTransformRules Rules = FAttachmentTransformRules(EAttachmentRule::SnapToTarget,
|
|
||||||
EAttachmentRule::KeepRelative,
|
|
||||||
EAttachmentRule::KeepRelative,
|
|
||||||
false);
|
|
||||||
|
|
||||||
Instance->AttachToComponent(ArmsMesh, Rules);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Weapons.IsEmpty())
|
if (!Weapons.IsEmpty())
|
||||||
|
@ -6,10 +6,11 @@
|
|||||||
#include "LMAmmo.h"
|
#include "LMAmmo.h"
|
||||||
#include "LMWeaponDataStructure.h"
|
#include "LMWeaponDataStructure.h"
|
||||||
#include "GameFramework/Actor.h"
|
#include "GameFramework/Actor.h"
|
||||||
#include "GameFramework/SpringArmComponent.h"
|
|
||||||
#include "LMWeaponBase.generated.h"
|
#include "LMWeaponBase.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ALMPlayer;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class LEGUMEMIX_API ALMWeaponBase : public AActor
|
class LEGUMEMIX_API ALMWeaponBase : public AActor
|
||||||
{
|
{
|
||||||
@ -18,6 +19,7 @@ class LEGUMEMIX_API ALMWeaponBase : public AActor
|
|||||||
public:
|
public:
|
||||||
ALMWeaponBase();
|
ALMWeaponBase();
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
void Setup(USkeletalMeshComponent* Mesh, AActor* CharOwner);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
@ -70,6 +72,10 @@ protected: /* Weapon Data */
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
|
||||||
int ClipAmmo;
|
int ClipAmmo;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category=Legumix)
|
||||||
|
TObjectPtr<ALMPlayer> Player;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true))
|
||||||
FDataTableRowHandle DataTableRow;
|
FDataTableRowHandle DataTableRow;
|
||||||
|
Reference in New Issue
Block a user