Getting values to change over time

I’m struggling at the moment. I understand most of the concepts of UE4 and have seen more tutorial videos on the subject than Scottish people voted SNP, but I have a stumbling block.

I am trying to create an NPC that has attributes that change over time, for instance, they get hungry or thirsty. I know how to create the character, I know how to get them to react to being hungry, I just can’t seem to make them get hungry! I have a variable called Hunger that I have set a max value of 30, and the default for the game starts as 0, so I want it to climb steadily as the level plays out and once they reach a hunger of 20 they move a little slower, and if they reach 25 they go half speed and if they reach 30 they stop moving and complain bitterly about food (like any one of my 4 children about 10 minutes after dinner time).

If anyone can point me in the right direction that will be great.

Cheers

Kevin

You can use a looping timer to increase a variable every x amount of seconds.

Docs:
https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseTimers/Blueprints/index.html

Video tut (by tesla)

Thanks TK-Master, Hurdle one has now been overcome.

For your problem i would rather use Interface and one timer in for eg. level blueprint or in player pawn or somewhere more global.

So make interface, create function that reacts to when interface is called. In that function do your timed logic like hunger etc.
Then from level blueprint (or player controller) call that function for all actors with that interface.
This way you have only one timer and central place to change its frequency etc.
Much better than making one timer per actor.

Also some thought about timers, that i am not sure if i am right or not:
To me it looks like when some blueprint actor which has timer gets destroyed in not quite clean way it can sometimes leave active timer.
That timer will keep calling function from destryed actor and potentially allocated memory for something new. Really easy way for crash.
In september or so I used lots of timers and got strange crashes, when i changed all to single timer and interfaces everything became more stable.
I also do not use timer for master function, i just check game time seconds in event tick, and call my master timer logic every 0.2 sec.
Which is plenty for hp, hunger, and such updates.

Yes, very simple. To do an exponentially slower hunger increase, just do something like


hunger = hunger + ((1 * (60 / (hunger + 30) ) ) / 2) 

The equation above will have hunger drop 2x as fast when hunger is 1 as when it’s 30.