diff --git a/Content/Blueprints/Weapon/Projectiles/BP_ProjectileBullet.uasset b/Content/Blueprints/Weapon/Projectiles/BP_ProjectileBullet.uasset index 367e585..7fe9613 100644 Binary files a/Content/Blueprints/Weapon/Projectiles/BP_ProjectileBullet.uasset and b/Content/Blueprints/Weapon/Projectiles/BP_ProjectileBullet.uasset differ diff --git a/Content/Maps/BlasterMap.umap b/Content/Maps/BlasterMap.umap index 4608d86..fac04cc 100644 Binary files a/Content/Maps/BlasterMap.umap and b/Content/Maps/BlasterMap.umap differ diff --git a/Source/Blaster/Weapon/Projectile.h b/Source/Blaster/Weapon/Projectile.h index e21c680..db0da77 100644 --- a/Source/Blaster/Weapon/Projectile.h +++ b/Source/Blaster/Weapon/Projectile.h @@ -16,6 +16,14 @@ public: AProjectile(); virtual void Tick(float DeltaTime) override; + // Used with server-side rewind + bool bUseServerSideRewind = false; + FVector_NetQuantize TraceStart; + FVector_NetQuantize100 InitialVelocity; + + UPROPERTY(EditAnywhere) + float InitialSpeed = 15000; + protected: virtual void BeginPlay() override; void StartDestroyTimer(); diff --git a/Source/Blaster/Weapon/ProjectileBullet.cpp b/Source/Blaster/Weapon/ProjectileBullet.cpp index 74231c7..9dfd523 100644 --- a/Source/Blaster/Weapon/ProjectileBullet.cpp +++ b/Source/Blaster/Weapon/ProjectileBullet.cpp @@ -12,6 +12,8 @@ AProjectileBullet::AProjectileBullet() ProjectileMovementComponent = CreateDefaultSubobject(TEXT("ProjectileMovementComponent")); ProjectileMovementComponent->bRotationFollowsVelocity = true; ProjectileMovementComponent->SetIsReplicated(true); + ProjectileMovementComponent->InitialSpeed = InitialSpeed; + ProjectileMovementComponent->MaxSpeed = InitialSpeed; } void AProjectileBullet::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) @@ -28,3 +30,24 @@ void AProjectileBullet::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, Super::OnHit(HitComp, OtherActor, OtherComp, NormalImpulse, Hit); } + +void AProjectileBullet::BeginPlay() +{ + Super::BeginPlay(); + + FPredictProjectilePathParams PathParams; + PathParams.bTraceWithChannel = true; + PathParams.bTraceWithCollision = true; + PathParams.DrawDebugTime = 5.f; + PathParams.DrawDebugType = EDrawDebugTrace::ForDuration; + PathParams.LaunchVelocity = GetActorForwardVector() * InitialSpeed; + PathParams.MaxSimTime = 4.f; + PathParams.ProjectileRadius = 5.f; + PathParams.SimFrequency = 30.f; + PathParams.StartLocation = GetActorLocation(); + PathParams.TraceChannel = ECollisionChannel::ECC_Visibility; + PathParams.ActorsToIgnore.Add(this); + + FPredictProjectilePathResult PathResult; + UGameplayStatics::PredictProjectilePath(this, PathParams, PathResult); +} diff --git a/Source/Blaster/Weapon/ProjectileBullet.h b/Source/Blaster/Weapon/ProjectileBullet.h index 1631542..ca15f10 100644 --- a/Source/Blaster/Weapon/ProjectileBullet.h +++ b/Source/Blaster/Weapon/ProjectileBullet.h @@ -21,5 +21,5 @@ public: protected: virtual void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit) override; - + virtual void BeginPlay() override; };