I was trying to rotate turret back to default rotation by using GetActorForwardVector(), but it is giving me fixed location in the world map, unlike in Crypt Raider. Why is this and how can I fix?
this is also happening to Tank
Super::Tick(DeltaTime);
DrawDebugLine(GetWorld(), GetActorLocation(), DefaultRotation, FColor::Red, false, 1.f);
DrawDebugSphere(GetWorld(), GetActorLocation(), 100.f, 13, FColor::Cyan, false, 1.f);
DrawDebugSphere(GetWorld(), GetActorForwardVector(), 100.f, 12, FColor::Blue, false, 1.f);
// Find the distance to the Tank
if (Tank)
{
float Distance = FVector::Dist(GetActorLocation(), Tank->GetActorLocation());
// Check to see if the Tank is in range
if(Distance < FireRange)
{
// If in range, rotate turret toward Tank
RotateTurret(Tank->GetActorLocation());
}
else
{
RotateTurret(GetActorForwardVector());
}
}