AI Data Provider How to?

I can’t find anything on how to use the data provider and it looks like something I want to use. Any chance there is a write up on how to use it somewhere, that I’m missing?

1 Like

I don’t think it’s documented anywhere. Data providers are currently used by EQS to create parameters that can be changed in runtime or based on some gameplay criteria, but in general, they can be used anywhere in code.

FAIDataProviderValue

Structure with dynamic parameter’s value, commonly used via derived structs: FAIDataProviderIntValue, FAIDataProviderFloatValue and FAIDataProviderBoolValue. Important member variables:

  • DataBinding is instanced object with UPROPERTY holding value which will be passed to data provider
  • DataField is optional and used (and displayed) only if DataBinding has more than one member property with matching type (e.g. MyPawnProvider with 3 floats: MaxHP, CurrentHP, Speed). Grouping properties together is less efficient, since you’ll need to bind them all, but still useful.

You always need to call BindData() function before accessing value. Owner and RequestId params are whatever your DataBinding uses to work. In case of EQS, this is actor requesting query and query Id. Once data is prepared, you can either use GetValue() helper function (float/int/bool) or use GetRawValuePtr() to read directly from bound property.

Check UEnvQueryTest_Distance::RunTest for example use case.

UAIDataProvider

Object providing data. A few things to keep in mind:

  • requires UPROPERTIES to interact with data provider structs
  • this object should be used through struct wrappers (e.g. default value support)
  • EditInlineNew class flag

Override BindData() and use it to initialize your properties with values. In case of EQS, Owner will be usually a Pawn. ToString() can be left alone, unless you need custom descriptions for provider and field pairs (property names, not values).

Existing providers:

So far only one at engine level - QueryParams. It gives access to float / int / bool named parameters passed with query execution (usually with FEnvQueryRequest.Set***Param functions)

2 Likes