This is the struct that I’m sending in my actor component.
#pragma once
#include "PlayerInputState.generated.h"
USTRUCT()
struct FPlayerInputState
{
GENERATED_USTRUCT_BODY()
FPlayerInputState()
: xAxis(0.0f), yAxis(0.0f), zAxis(0.0f), pitch(0.0f), roll(0.0f), yaw(0.0f), timestamp(0.0f) {}
FPlayerInputState(float a_xAxis, float a_yAxis, float a_zAxis, float a_pitch, float a_roll, float a_yaw, float a_timestamp)
: xAxis(a_xAxis), yAxis(a_yAxis), zAxis(a_zAxis), pitch(a_pitch), roll(a_roll), yaw(a_yaw), timestamp(a_timestamp) {}
UPROPERTY(Replicated)
float xAxis;
UPROPERTY(Replicated)
float yAxis;
UPROPERTY(Replicated)
float zAxis;
UPROPERTY(Replicated)
float pitch;
UPROPERTY(Replicated)
float roll;
UPROPERTY(Replicated)
float yaw;
UPROPERTY(Replicated)
float timestamp;
};
This is the actual function setup.
// HEADER
UFUNCTION(Server, WithValidation, Unreliable)
void ServerSendInput(FPlayerInputState a_inputState);
// CPP
void UNetworkedMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// Testing shows LocalPlayerInput (an FPlayerInputState struct member of this component) has non-zero values
if (GetOwner()->Role < ROLE_Authority)
{
ServerSendInput(LocalPlayerInput);
}
}
void UNetworkedMovementComponent::ServerSendInput_Implementation(FPlayerInputState a_inputState)
{
// in here, a_inputState's variables/members are zero, no matter what is originally sent.
}
bool UNetworkedMovementComponent::ServerSendInput_Validate(FPlayerInputState a_inputState)
{
return true;
}
Anyone have any ideas why the struct’s member variables aren’t coming across in the RPC? I also tried with const FPlayerInputState& arguments, but same result.