22 lines
673 B
C++
22 lines
673 B
C++
// ProjeLab - NHTV Igad
|
|
|
|
#include "UnrealProject.h"
|
|
#include "HoverProjectile.h"
|
|
|
|
|
|
|
|
|
|
|
|
void AHoverProjectile::NativeMove(float DeltaTime)
|
|
{
|
|
//moves with sweep to get collision
|
|
float distance = speed * DeltaTime;
|
|
FVector newpos = GetActorForwardVector() * distance + GetActorLocation();
|
|
FHitResult outHit;
|
|
FVector offset;
|
|
if (GetWorld()->LineTraceSingleByChannel(outHit, newpos, newpos - FVector(0, 0, hoverHeight + 10), ECollisionChannel::ECC_GameTraceChannel7))
|
|
offset = outHit.ImpactPoint + FVector(0, 0, hoverHeight) - GetActorLocation();
|
|
else
|
|
offset = newpos - FVector(0, 0, 10) - GetActorLocation();
|
|
AddActorWorldOffset(offset,true);
|
|
} |