Download

Changes made in Blueprint Editor not evident in gameplay.

Hi,
I’ve been following the “Battery Collector” tutorial on youtube for the second time (haven’t touched anything Unreal in about a year) to refresh my memory before tackling anything more ambitious
I’ve decided to change the behaviour of the BatteryPickup class so that the power level is random for each spawned instance, a Blueprint class (Battery_BP) is derived from BatteryPickup and used for spawning. I have created two protected float variables in BatteryPickup.h to represent the upper and lower limits to pass to FMath::RandRange(). They are both marked up as

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “Power”, Meta = (BlueprintProtected = “true”))

in the header and given default values in BatteryPickups’ constructor.

Unfortunately whilst these values are indeed visible and editable in the Blueprint Editor, the values do not show in gameplay instead the default values supplied in the constructor persist.

I am using Windows 10 insider preview, Visual Studio 2019, and Unreal Engine 4.24.3 installed build.

Here is my code:

BatteryPickup.h:


#pragma once

#include "CoreMinimal.h"
#include "Pickup.h"
#include "BatteryPickup.generated.h"

/**
 *
 */
UCLASS()
class BATTERYCOLLECTOR_API ABatteryPickup : public APickup
{
    GENERATED_BODY()

public:
    // Sets default values for this actor's properties
    ABatteryPickup();

    // Override AcknowledgeCollection()
    // use Implementation due to AcknowledgeCollection() being Blueprint Native
    void AcknowledgeCollection_Implementation() override;

    // Public way to access battery power level
    float GetPowerLevel() const;

protected:
    // Battery power lower limit
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected = "true"))
    float BatteryPowerRangeLow;
    // Battery power upper limit
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected = "true"))
    float BatteryPowerRangeHigh;

private:
    // The amount of power the battery possesses
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Power", Meta = (AllowPrivateAccess = "true"))
    float BatteryPower;
};

BatteryPickup.cpp:


#include "BatteryPickup.h"

ABatteryPickup::ABatteryPickup()  
{
    GetMesh()->SetSimulatePhysics(true);

    BatteryPowerRangeLow = 0.2f;
    BatteryPowerRangeHigh = 13.0f;

    // Set random Battery power level
    BatteryPower = FMath::RandRange(BatteryPowerRangeLow, BatteryPowerRangeHigh);

}

void ABatteryPickup::AcknowledgeCollection_Implementation()
{
    // Debug string to return object name to Log
    FString BatteryName = GetName();
    // Log Collection with name and power level
    UE_LOG(LogClass, Log, TEXT("Collected %s - Power Level = %f"), *BatteryName, GetPowerLevel())

    // Destroy the battery
    Destroy();
}

ANY insight into why I am unable to change these variables would be greatly appreciated.
Cheers.