Configure Character visibility in a local multiplayer game?

Hi all,

I am trying to implement some logic to hide my character to other enemy players but make It visible to my team. I experimented with the “Only Owner See” property and It hides the character mesh as I expected, however It is hidden for all but me.

I am testing this with other local players in Split screen mode. I created two base actors(one for each team) and I set them to owner respectively for each player character

Any ideas how I could achieve this behavior?

This is how I created the local player characters:

I test with this in my character:

313283-ch-hide.png

Thank you

Hi,

After digging into the code, I found that PlayerController class has an array with actors to ignore. I just add the actors I need to hide to this array and It works at least for Local split screen players.

/** The actors which the camera shouldn't see - e.g. used to hide actors which the camera penetrates */
UPROPERTY()
TArray<class AActor*> HiddenActors;

Example:
.cpp

void AMainPlayerController::AddActorHidden(AActor* ActorToHide)
{
	HiddenActors.AddUnique(ActorToHide);
}
void AMainPlayerController::RemoveActorHidden(AActor* ActorToRemove)
{
	HiddenActors.Remove(ActorToRemove);
}

.hpp

UCLASS()
class AMainPlayerController : public APlayerController
{
	GENERATED_BODY()
public:
	UFUNCTION(BlueprintCallable, Category = "Invisibility")
		void AddActorHidden(AActor* ActorToHide);

	UFUNCTION(BlueprintCallable, Category = "Invisibility")
		void RemoveActorHidden(AActor* ActorToRemove);
1 Like