Character Reference - variables returning 0 in Widget

Hi Guys,

I’m trying to create a calibration test for one of my main menus. When the calibration button is clicked it should read the heart rate coming from the player character (this is gotten via arduino and works as it prints them out to the screen on begin play).

The plan is to get the heart rate every second for 60 seconds, add it to the average heart rate and after the loop, divide by 60 and set it as the variable for average heart rate. The print out to screen are showing that the heart rate is 0 constantly, when the game is played the heart rate is showing average values like 73,74 etc.

I’m thinking it may be the reference of the MySacredHeartCharacter?

I ran into this trying to pass variables from a widget to the character blueprint. You will have to Cast to FirstPersonCharacter (if using FPS Setup) and then drag your variable references off of the return.

Thank you so much! That did the trick!! Now I just need to figure out how to get the loop to delay 1 second each iteration and it’s done!

You are welcome! You could use an event timer in place of the for loop and set it to loop at the time you want. Set an integer with each time the timer fires until it adds up to the number you want then set looping to false.For loops run with each frame of the game and I am not sure how to delay them. You may get an extra tick but you’ll have to play with it a bit.

EDIT: You will want to enable looping (Set Looping True) after the timer otherwise it will not loop when you execute it.