How to ignore both the Client and the Server version of Characters on Traces?

Hello :slight_smile:

I’m currently using a system very close to @Rama’s trace function to do traces.

And, while using it, I frequently run into the problem of the function colliding with a non-existing version of the player - i.e. When I look at UE4Editor, I see my player character, and can’t find the +1 version of it, like in this debug message:

LogHavenWeapon:Error: [0] Our own block: BP_Block2x3_C_88. Is Owned by the player to be ignored (owner): false. Owner: BP_Haven_Engineer_C_151. Player to be ignored: BP_Haven_Engineer_C_150

I tried modifying it the function to use ignore arrays (it required a lot of changes, but I was hoping that instead of looking for my object, I could look for a open space). Didn’t work - First line displays the array of ignored actors, second line, the blocking actor and it’s owner:

LogHavenWeapon:Error: Ignore1: BP_Haven_Engineer_C_0. Ignore2: BP_Block2x3_C_0.
LogHavenWeapon:Error: [0] Actor Blocking: BP_Block2x3_C_1. Owner: BP_Haven_Engineer_C_1.

After a lot of research, I came to the conclusion it’s getting nuts trying to differentiate the client and server version of the actors. I can’t prove it, but it’s the only explanation that made sense.

Is there a way to verify if my “BP_Block2x3_C_0” is the same as “BP_Block2x3_C_1”, on the server and on the client ?

Also, it’s worth noting that I only found this bug while in the editor, and only when there are at least 2 players connected - but I did very few tests on the packaged game. Whenever I tried it in the packaged game, I didn’t hit that problem.

Thank you in advance, I hope you can give me some aid to hunt down and kill this nightmare. :slight_smile:

Update: I couldn’t change “Characters” to “Actors” on the thread subject after I submitted. I’m willing to correlate client and server actors here, so I can ignore them :slight_smile:

Its indeed unnecessary to try to differentiate between client and server version of an actor. The fact is that there will be only one in the server’s world and one in the client’s world.

Are those log messages being printed from the same client? Or is one printed from server and the other from client?

Are you sure that your client doesn’t run any actor spawning logic? That would introduce duplicate actors on the client, which aren’t present on the server.

They are only printed with 2+ players are run from UE4Editor. With standalone/packaged clients, my functions work perfectly.
I still don’t know how to solve this :confused:

Perhaps you could post your actor spawning, trace and logging code and maybe some screenshots.

Running the console command ‘pxvis collision’ may help too. It displays all collision shapes, i.e. what can respond to traces.

I can’t post all of the code since it’s very complex. (it has tons of supporting code for various functions of the game)

Basically, I spawn an actor like this, in a weapon (this can easily be adapted to the character):

		FVector SpawnLocation(0, 0, 450);
		FRotator SpawnRotation(0, 0, 0);

		FActorSpawnParameters SpawnParams;
		SpawnParams.Owner = GetPawnOwner(); // change to "this" if doing this on the character

		ABaseBlock* ManipulatedBlock = World->SpawnActor<ABaseBlock>(GetPawnOwner()->GetNewBlockType(), SpawnLocation, SpawnRotation, SpawnParams);
		GetPawnOwner()->SetManipulatedBlock(ManipulatedBlock); // Keep a pointer to this actor on the player character

And on the Character, I have a function that runs on the Tick() if the manipulated block is set, to keep it in front of the player at all times

	FVector BlockPosition = GetActorLocation();	// Get this character location									
	FVector PlayerFacingDirection = GetControlRotation().Vector();					
	BlockPosition += (PlayerFacingDirection * 500.0f);

Then I use one of the mentioned @Rama traces functions to check if there is something between the player and the spawned block.
If it hits the block that we are currently carrying, it is a valid position. I add the player character to the ignored list of actors to do this.

The problem is that often I’m hitting one of those “imaginary” blocks when testing the game with 2+ players in the Editor . (this haven’t happened - at least not yet - when using the packaged version of the game)

Hopefully you can reproduce the problem with those steps :smiley:

Thank you in advance!

Does the spawning code execute only on server, only on client or on both?

Currently, the spawning function is being called inside the function [FONT=Courier New]HandlePrimaryFiring() (Same function from ShooterGame), but there is a check right off the bat:

	if (Role < ROLE_Authority)

So, it’s only being called on the server :slight_smile:

Edit: Now it’s better

Okay, so I did some testing and apparently server and client versions of the same actor don’t have to have the same name at all. In editor they will most likely be different even, because the editor by default runs all game instances on the same process, so they use the same counter: server spawns actor which gets suffix 0, client-side creates the local version of actor which then gets suffix 1.

So yeah, serverside and clientside actors with different names can still represent the same actor. But still that shouldn’t be an issue because if you pass a reference to the actor between server and client, the engine will always resolve to the right actor in that game instance.