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)
|
||||
{
|
||||
FVector EndLocation = Settings.Origin + (Settings.Direction * Settings.MaxDistance);
|
||||
TArray<FHitResult> Hits;
|
||||
DrawDebugLineTraceMulti(GetWorld(), Settings.Origin, EndLocation, EDrawDebugTrace::ForDuration, true, Hits, FColor::Green, FColor::Red, 10.f);
|
||||
TArray<FHitResult> Hits = TArray<FHitResult>();
|
||||
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)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
@ -15,7 +15,6 @@ ALMShotgun::ALMShotgun()
|
||||
|
||||
void ALMShotgun::PrimaryFire()
|
||||
{
|
||||
ALMPlayer* Player = Cast<ALMPlayer>(GetOuter());
|
||||
if (!Player)
|
||||
return;
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "Weapon/LMWeaponBase.h"
|
||||
|
||||
#include "Components/AudioComponent.h"
|
||||
#include "Player/LMPlayer.h"
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
@ -27,16 +27,8 @@ void ULMWeaponManager::Initialize(USkeletalMeshComponent* Mesh)
|
||||
|
||||
ALMWeaponBase* Instance = GetWorld()->SpawnActor<ALMWeaponBase>(WeaponTemplate);
|
||||
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 2.f, FColor::Blue, TEXT("Spawing"));
|
||||
Instance->SetActorHiddenInGame(true);
|
||||
|
||||
Instance->Setup(ArmsMesh, GetOwner());
|
||||
Weapons.Add(Instance);
|
||||
|
||||
FAttachmentTransformRules Rules = FAttachmentTransformRules(EAttachmentRule::SnapToTarget,
|
||||
EAttachmentRule::KeepRelative,
|
||||
EAttachmentRule::KeepRelative,
|
||||
false);
|
||||
|
||||
Instance->AttachToComponent(ArmsMesh, Rules);
|
||||
}
|
||||
|
||||
if (!Weapons.IsEmpty())
|
||||
|
@ -6,10 +6,11 @@
|
||||
#include "LMAmmo.h"
|
||||
#include "LMWeaponDataStructure.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "LMWeaponBase.generated.h"
|
||||
|
||||
|
||||
class ALMPlayer;
|
||||
|
||||
UCLASS()
|
||||
class LEGUMEMIX_API ALMWeaponBase : public AActor
|
||||
{
|
||||
@ -18,6 +19,7 @@ class LEGUMEMIX_API ALMWeaponBase : public AActor
|
||||
public:
|
||||
ALMWeaponBase();
|
||||
virtual void BeginPlay() override;
|
||||
void Setup(USkeletalMeshComponent* Mesh, AActor* CharOwner);
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
@ -70,6 +72,10 @@ protected: /* Weapon Data */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
|
||||
int ClipAmmo;
|
||||
|
||||
UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category=Legumix)
|
||||
TObjectPtr<ALMPlayer> Player;
|
||||
|
||||
|
||||
private:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true))
|
||||
FDataTableRowHandle DataTableRow;
|
||||
|
Reference in New Issue
Block a user