I came across a problem, when i tried to make a turret look at the player. Other post on the HUB was not helpful to me
It was fairly easy in Blueprint.
My problem is that i cant acces the FindLookatRotation() function in C++.
void ATurretC::TickActor(float DeltaTime, enum ELevelTick TickType, FActorTickFunction& ThisTickFunction)
{
if (PlayerInside)
{
FVector PlayerLoc = GetWorld()->GetFirstPlayerController()->GetCharacter()->GetActorLocation();
FRotator PlayerRot = UKismetMathLibrary::FindLookAtRotation(this->GetActorLocation,PlayerLoc);
FRotator NewRot = FMath::RInterpTo(StaticMesh2->GetComponentRotation(), PlayerRot, DeltaTime, 2);
}
else
{
// TODO, Set rot back to Default
//RootComponent->SetWorldRotation(FRotator(0, 0, 0));
}
}
Error: ‘FRotator UKismetMathLibrary::FindLookAtRotation(const FVector &,const FVector &)’ : cannot convert argument 1 from ‘overloaded-function’ to ‘const FVector &’
1> Reason: cannot convert from ‘overloaded-function’ to ‘const FVector’
Any other solution to replace UKismetMath Library?
Hmm… I think the error say you are passing the function an overloaded function instead of FVector.
The reason for that is that you are missing parenthesis after GetActorLocation at line 6.
Instead of:
Hello !
I think the problem is firstly coming from the fact that you are not actually calling the function GetActorLocation() because you have forgotten the parentheses.
Also, your implementation seem to be not the best way to implement a turret looking at the player (if i got it right). I would suggest to set the actor rotation to the rotation the UKismetMathLibrary::FindLookAtRotation() returns.