So I have this code that makes my object “look” at the player.
FVector selfLocation = VisibleComponent->GetComponentLocation(); FVector playerLocation = (UGameplayStatics::GetPlayerCharacter(GetWorld(),0))->GetActorLocation(); FRotator deltaRotate = (selfLocation - playerLocation).Rotation(); VisibleComponent->SetWorldRotation(deltaRotate);
What I don’t understand is this line
FRotator deltaRotate = (selfLocation - playerLocation).Rotation();. How is rotation calculated ? isnt FVector just a collection of 3 variables (X, Y, Z) ?
And why does this work ? I dont understand how can you get the rotation just by substracting the locations…