Download

Containing a Data Sheet

I wanted a structured way of storing related data for a character. For instance I want to do a more complex movement system that has some default values. For instance my idea is currently to store movement data in a struct inside the character class header like this,



...
USTRUCT()
struct FMovementDataSheet
{
  GENERATED_BODY()


private:
  UPROPERTY()
  float BaseSpeedFactor(int)EBaseMovementMode::BaseMovementModeCount] = {NULL, 0.0f, 0.15f, 0.4f, 0.65f, 1.1f };

  // Exertion rate per second
  float BaseExertionFactor(int)EBaseMovementMode::BaseMovementModeCount] = { NULL, 0.0f, 0.0f, 0.0f, 0.5f, 4.0f };
public:
  float GetBaseSpeedFactor(EBaseMovementMode BaseMovementMode) const { return BaseSpeedFactor(int)BaseMovementMode]; }

};
...


So far GetBaseSpeedFactor is then called when calculating the movement speed of the character when either walking, running or whatever, and eventually other effects, such as encumberance or buffs/debuffs are to be applied onto the movement as well.

However, as newbie, is this the ue-way of storing this kind of data? I tried looking into various examples of code, but I didn’t feel like I found anything to compare with.
Or would the better way perhaps be to create a new class that simply embodies the movement/character mechanics inside the class itself and then inherit from that one?

Also, a bonus question, if I may: Is there a way to initialise and declare a TArray? const C++ type arrays don’t seem to work with unreal engine.

Google “UE4 Data Tables” and/or data assets