Hi all,
I have a plane_bp blueprint that uses the Easy Flight Model plugin component for flight mechanics.
The blueprint’s parent class is SBaseAircraft which has a replicated Fuel variable that slowly decreases on beginplay:
UFUNCTION(BlueprintCallable, Category = "AircraftCondition")
float GetFuel() const;
UFUNCTION(BlueprintCallable, Category = "AircraftCondition")
float GetMaxFuel() const;
UPROPERTY(EditDefaultsOnly, Category = "AircraftCondition", Replicated)
float Fuel;
UPROPERTY(EditDefaultsOnly, Category = "AircraftCondition")
float MaxFuel;
// Decrements fuel, used by timer.
void DecrementFuel();
The player blueprint parent is a Character class which contains a replicated variable called CurrentAircraft of type SBaseAircraft, and another variable called CurrentAircraftType, which is set as the plane_bp blueprint:
UPROPERTY(EditAnywhere, meta = (AllowPrivateAccess = "true"))
TSubclassOf<class ASBaseAircraft> CurrentAircraftType;
UPROPERTY(Transient, Replicated)
class ASBaseAircraft* CurrentAircraft;
UFUNCTION(BlueprintCallable)
ASBaseAircraft* GetAircraft() const;
Whenever a player spawns in, the plane_bp is spawned in with the player and the CurrentAircraft is set to the aircraft that was just spawned in:
void ASCharacter::BeginPlay()
{
Super::BeginPlay();
FActorSpawnParameters SpawnParams;
CurrentAircraft = (class ASBaseAircraft*)GetWorld()->SpawnActor(CurrentAircraftType.Get(), &GetActorTransform(), SpawnParams);
}
I’m trying to print out the player’s CurrentAircraft’s fuel every tick:
But only the server shows fuel decreasing from 100, and the client is for some reason 0:
If I uncheck the ‘replicates’ box in the plane_bp blueprint, the server and the client show the correct fuel counter - but the plane’s movements are not replicated:
I’d really appreciate anyone’s help with this. Thank you.