diff --git a/Content/Blueprints/Character/BP_BlasterCharacter.uasset b/Content/Blueprints/Character/BP_BlasterCharacter.uasset index ab88639..624bf64 100644 Binary files a/Content/Blueprints/Character/BP_BlasterCharacter.uasset and b/Content/Blueprints/Character/BP_BlasterCharacter.uasset differ diff --git a/Content/Blueprints/Weapon/Projectiles/BP_Projectile.uasset b/Content/Blueprints/Weapon/Projectiles/BP_Projectile.uasset index 941c50a..e292354 100644 Binary files a/Content/Blueprints/Weapon/Projectiles/BP_Projectile.uasset and b/Content/Blueprints/Weapon/Projectiles/BP_Projectile.uasset differ diff --git a/Source/Blaster/Weapon/Projectile.cpp b/Source/Blaster/Weapon/Projectile.cpp index 3a6e05c..4b1a5a5 100644 --- a/Source/Blaster/Weapon/Projectile.cpp +++ b/Source/Blaster/Weapon/Projectile.cpp @@ -5,12 +5,14 @@ #include "Components/BoxComponent.h" #include "GameFramework/ProjectileMovementComponent.h" +#include "Kismet/GameplayStatics.h" AProjectile::AProjectile() { PrimaryActorTick.bCanEverTick = true; + bReplicates = true; - CollisionBox = CreateDefaultSubobject(TEXT("CollisionBox"));\ + CollisionBox = CreateDefaultSubobject(TEXT("CollisionBox")); SetRootComponent(CollisionBox); CollisionBox->SetCollisionObjectType(ECollisionChannel::ECC_WorldDynamic); CollisionBox->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); @@ -25,12 +27,21 @@ AProjectile::AProjectile() void AProjectile::BeginPlay() { Super::BeginPlay(); - + + if (Tracer) + { + TracerComponent = UGameplayStatics::SpawnEmitterAttached( + Tracer, + CollisionBox, + FName(), + GetActorLocation(), + GetActorRotation(), + EAttachLocation::KeepWorldPosition + ); + } } void AProjectile::Tick(float DeltaTime) { Super::Tick(DeltaTime); - } - diff --git a/Source/Blaster/Weapon/Projectile.h b/Source/Blaster/Weapon/Projectile.h index 2762900..adefdeb 100644 --- a/Source/Blaster/Weapon/Projectile.h +++ b/Source/Blaster/Weapon/Projectile.h @@ -4,6 +4,7 @@ #include "CoreMinimal.h" #include "GameFramework/Actor.h" +#include "Particles/ParticleSystemComponent.h" #include "Projectile.generated.h" UCLASS() @@ -25,4 +26,9 @@ public: UPROPERTY(VisibleAnywhere) class UProjectileMovementComponent* ProjectileMovementComponent; + + UPROPERTY(EditAnywhere) + class UParticleSystem* Tracer; + + class UParticleSystemComponent* TracerComponent; }; diff --git a/Source/Blaster/Weapon/ProjectileWeapon.cpp b/Source/Blaster/Weapon/ProjectileWeapon.cpp index 1bfcb8d..1488240 100644 --- a/Source/Blaster/Weapon/ProjectileWeapon.cpp +++ b/Source/Blaster/Weapon/ProjectileWeapon.cpp @@ -10,6 +10,8 @@ void AProjectileWeapon::Fire(const FVector& HitTarget) { Super::Fire(HitTarget); + if (!HasAuthority()) return; + APawn* InstigatorPawn = Cast(GetOwner()); const USkeletalMeshSocket* MuzzleFlashSocket = GetWeaponMesh()->GetSocketByName(FName("MuzzleFlash")); if (MuzzleFlashSocket)