I have Character set up to show tooltip when he looks at pickup:
void AMyCharacter::Tick(float DeltaSeconds){
Super::Tick(DeltaSeconds);
FHitResult Hit;
FVector StartLocation = GetActorLocation();
FVector EndLocation = StartLocation + GetViewRotation().Vector() * 200;
if (GetWorld()->LineTraceSingle(Hit, StartLocation, EndLocation, ECC_Camera, FCollisionQueryParams(GetClass()->GetFName(), false, this))){
APickup* LookingAt = Cast<APickup>(Hit.Actor.Get());
if (LookingAt){
GEngine->AddOnScreenDebugMessage(-1, 10.0, FColor::Yellow, TEXT("i see"));
LookingAt->ShowTooltip(this);
}
}
}
In Weapon_Pickup (child of pickup):
void APickup_Weapon::ShowTooltip(AMyCharacter* ToWho){
GEngine->AddOnScreenDebugMessage(-1, 10.0, FColor::Yellow, TEXT("turning on text"));
Tooltip->SetVisibility(true);
}
Problem is - the text does become visible for everyone except the player who i looked at it with, i tested it with multiple different players looking at pickup.
Additional question that i’d like here, because it doesn’t deserve it’s own thread - how to check if character is controled by local player?