194 - Predict Projectile Path
This commit is contained in:
parent
8feb5dcbad
commit
fec03cfb8e
Binary file not shown.
Binary file not shown.
|
@ -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();
|
||||
|
|
|
@ -12,6 +12,8 @@ AProjectileBullet::AProjectileBullet()
|
|||
ProjectileMovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue