Download

Select a character with the mouse

I am trying to implement selecting a character with the mouse.
For that I need to click the character with my mouse and check if the hitting actor was the character.
So I have been trying this:


	if (AVikingKingPlayerController::leftMouseClicked)
	{
		FHitResult hit;
		GetWorld()->GetFirstPlayerController()->GetHitResultUnderCursor(ECC_Visibility, false, hit);
		

		AViking* obj = Cast<AViking>(hit.GetActor());

		if (hit.bBlockingHit && obj && obj->GetController() == Controller)
		{
			GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, "character has been clicked!");
		}
	}

But I do not get the “character has been clicked!” message.
So how can I check if the object which was click is a specific actor?

UP…