References and Blueprints

In my character’s code, I want to be able to change GetCharacterMovement()->MaxWalkSpeed, so that when I’m sprinting, for instance, I can move faster than normal. However, I would not like to have to write that all the time, so I made a variable,

    float & DefaultSpeed = GetCharacterMovement()->MaxWalkSpeed;

However, I cannot make it a UPROPERTY, or UE4 will crash. How can I create a reference variable in C++ that can be seen and changed in blueprints?

Hello, Kowbell

Please note that usage of reference type as UPROPERTY makes sense in situation when the property is an object. However, for primitives, you can do something like this:

UPROPERTY(EditAnywhere, Category = MySettings)
float DefaultSpeed;

This way you’ll be able to access and edit the value in blueprint.

Hope this helped!

Have a great day!