# (Learning Agents) Getting observation data at each step for reward function

**URL:** <https://forums.unrealengine.com/t/learning-agents-getting-observation-data-at-each-step-for-reward-function/2724968>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Learning-Agents\
**Created:** [May 28, 2026, 5:54pm UTC](https://forums.unrealengine.com/t/learning-agents-getting-observation-data-at-each-step-for-reward-function/2724968 "2026-05-28T17:54:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hi\_i\_am\_fakroun](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hi\_i\_am\_fakroun](https://forums.unrealengine.com/u/hi_i_am_fakroun)\
**Post date:** [May 28, 2026, 5:54pm UTC](https://forums.unrealengine.com/t/learning-agents-getting-observation-data-at-each-step-for-reward-function/2724968/1 "2026-05-28T17:54:47Z")

</div>

I am trying to implement a reward function that depends on the observations made that step, basically when an observation is made, i need to retrieve that in order to calculate the reward for my agent.  
Is there a way to do this ?

---

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [May 28, 2026, 7:44pm UTC](https://forums.unrealengine.com/t/learning-agents-getting-observation-data-at-each-step-for-reward-function/2724968/2 "2026-05-28T19:44:20Z")

</div>

The simplest approach: cache the values yourself. You’re the one computing the observations in GatherAgentObservation, so just store them in member variables on your interactor (or trainer) and read them back in GatherAgentReward.

There’s no built in way to get the obs currently.
