Improbable Icon

Client authorative spatial component not syncing after updating packages to 0.4.0

Hello there!

I am in the process of updating our projects packages to 0.4.0.

So far most of the things went over smoothly but I am having trouble with one of my components called PlayerState.

This component is client authorative (the player can change a playerState Enum by pressing a button to tell the game he is ready to drive the gamestate).
Now since I have updated the packages following the upgrade guide for some reason changes made to this component get applied on the client, on the server however the component never recieves any updates anymore even tho the client component is changing.

I am currently at a loss as to why this is happening since there are no error messages at all.
I’d greatly appreciate any help!

Hi @r00f,

Can you share the code snippets where you’re sending and receiving the component update, as well as the .schema file for it?

Also, this is the only component with issues? The other components are still working fine?

Hi @JaySantos

Here is the schema:

package player;
import “cell/cell_attributes.schema”;
import “generic/vector3.schema”;
import “unit/actions.schema”;

component PlayerState {
id = 104;
PlayerStateEnum current_state = 1;
int64 selected_unit_id = 2;
generic.Vector3f selected_unit_coordinate = 3;
int32 selected_action_id = 6;
map<int64, CubeCoordinateList> unit_targets = 7;
bool end_step_ready = 8;
unit.Action selected_action = 9;
bool target_valid = 10;
bool target_dict_change = 11;
}
enum PlayerStateEnum {

waiting = 0;
unit_selected = 1;
waiting_for_target = 2;
ready = 3;

}

I am changing the PlayerState component from a clientside System like so:

m_PlayerData = GetEntityQuery(
ComponentType.ReadOnly<PlayerState.HasAuthority>(),
ComponentType.ReadWrite<PlayerState.Component>()
);

playerState.CurrentState = PlayerStateEnum.ready;

There is no code for recieving the Update on the server - before I updated the packages the server component recieved the update by just changing a value from the client side.

I am not seeing any issues with all of the components that get changed from the server side.

Hey @JaySantos I figured out what caused the Issue.

I was allocating the playerData in this system in a manner that stopped working with the new packages:

var playerStates = m_PlayerData.ToComponentDataArray<PlayerState.Component>(Allocator.TempJob);
var playerState = playerStates[0];
playerState.CurrentState = PlayerStateEnum.ready;
m_PlayerData.CopyFromComponentDataArray(playerStates);

Since I changed this allocation / CopyFromComponentDataArray into a Entities.ForEach loop the component gets the update correctly again.

1 Like