Updated CombatCharacter to Spawn GunEffect onClick
This commit is contained in:
parent
45374da8bb
commit
ed0bcc7c76
BIN
Content/Blueprints/Combat_UI/CombatCharacter.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/CombatCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
@ -65,6 +65,16 @@ void UHoldToInitCombat::OnRightClickDown()
|
|||||||
bRightClickDown = true;
|
bRightClickDown = true;
|
||||||
//InitCombatWidget->AddToViewport();
|
//InitCombatWidget->AddToViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GunEffect)
|
||||||
|
{
|
||||||
|
//Get Player Actor
|
||||||
|
const AActor* PlayerActor = GetWorld()->GetFirstPlayerController()->GetPawn();
|
||||||
|
//Get Static Mesh Location on the player actor
|
||||||
|
const UStaticMeshComponent* GunComponent = Cast<UStaticMeshComponent>(PlayerActor->GetComponentsByTag(UPrimitiveComponent::StaticClass(), FName("Gun"))[0]);
|
||||||
|
const FVector GunLocationOffset = GunComponent->GetSocketTransform("Muzzle").TransformPosition(FVector(-100, 0, 0));
|
||||||
|
UNiagaraFunctionLibrary::SpawnSystemAtLocation(GetWorld(), GunEffect, GunLocationOffset, PlayerActor->GetActorRotation());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UHoldToInitCombat::OnRightClickUp()
|
void UHoldToInitCombat::OnRightClickUp()
|
||||||
|
@ -4,8 +4,11 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Components/ActorComponent.h"
|
#include "Components/ActorComponent.h"
|
||||||
|
#include "NiagaraComponent.h"
|
||||||
|
#include "NiagaraFunctionLibrary.h"
|
||||||
#include "HoldToInitCombat.generated.h"
|
#include "HoldToInitCombat.generated.h"
|
||||||
|
|
||||||
|
class UNiagaraSystem;
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||||
class THE_TWILIGHT_ABYSS_API UHoldToInitCombat : public UActorComponent
|
class THE_TWILIGHT_ABYSS_API UHoldToInitCombat : public UActorComponent
|
||||||
@ -20,6 +23,9 @@ public:
|
|||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TSubclassOf<UUserWidget> InitCombatWidgetClass;
|
TSubclassOf<UUserWidget> InitCombatWidgetClass;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly)
|
||||||
|
UNiagaraSystem* GunEffect;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Called when the game starts
|
// Called when the game starts
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user