// Project Lab - NHTV Igad #include "UnrealProject.h" #include "BombProjectile.h" #include "NetworkCharacter.h" #include "Effect.h" #include "EffectFunctionLibrary.h" #include "BlueprintAbilityLibrary.h" ABombProjectile::ABombProjectile() { PrimaryActorTick.bCanEverTick = true; m_progress = 0.0f; maxDistance = 100000.0f; } void ABombProjectile::BeginPlay() { Super::BeginPlay(); travelTime = travelTime < 0.01f ? 0.01f : travelTime; float distance = FVector::Dist(source, target); } void ABombProjectile::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); DOREPLIFETIME_CONDITION(ABombProjectile, source, COND_InitialOnly); DOREPLIFETIME_CONDITION(ABombProjectile, target, COND_InitialOnly); DOREPLIFETIME_CONDITION(ABombProjectile, travelTime, COND_InitialOnly); } void ABombProjectile::NativeFixedProjectileTick(float DeltaTime) { if(travelTime <= 0 || m_finished) return; m_progress += DeltaTime; if(m_progress >= travelTime) m_progress = travelTime; const float lerp = m_progress / travelTime; const float sin = FMath::Sin(lerp * PI); FVector newLocation = FMath::Lerp(source, target, lerp) + FVector(0, 0, sin * travelHeight); SetActorLocation(newLocation, true); float distToEnd = (target - newLocation).Size(); if(lerp >= 1.0f) { // Server only Finish(); } }