Download

Interpolating an unchanging variable in UMG

Hey guys, in my quest to learn everything I can about UE I run into many problems. Some I figure out after an hour after I post it after days of messing around, some I figure out instantly. Some boggle me. This one is sortve boggleing me.

Ill first bring up I came to UE4 from Unity a few months before the ‘wave’ when everything went free.

I have a variable called screw_rpm (propeller rpm basically) that is calculated by dividing two variables, overall_acceleration by animation_speed_screw and then set. Animation speed screw is constant its used to set how fast the screws spin. Overall acceleration is set to the same value every time you press a key (num 5 = 5.0f, num 4 = 3.3667f, num 1 = 0.33334f etc) so I can already see how it would be hard to interpolate between values that dont constantly change. So of course, you think about time, as I remember from Unity Time.deltaTime and from UE4 it appears to be GetWorldDeltaSeconds(). I played around for a good chunk of the day trying to get this (among other things) to interpolate for a GUI. When I change engine speeds the player wont notice the animation speed change (although I intend to lerp that too,but one thing at a time as I learn), but they will notice the RPM going from 336 to 500 instantly.

Any ideas on how to do this in a widget class BP? Heres how I currently do it to get the instant change,

Heres (some of) the things I played with and at best I got the instant change, but they fluctuated slightly (probly due to the FPS going up or down a few)

I really feel like blueprint is making me forget all my programming habits and skills fast, but I suck at C++ and the Unreal API is almost alien to me, plus not being able to debug constantly is just… tough.

I apologize about the 2 postsi n the last 3 days.

Is there a way via BP to store a value temporily as a functions local variable or something from say 10-20-30 frames back and compare it to current value? That would make sense to me to help this along a bit, not to mention a few other lerping “bugs” or “innccuracies” in our pre-alpha whatever you wanna call them.

I’m guessing you’re updating that widget’s code every frame? It looks like what’s happening is that every frame your “current” value in the InterpTo node is getting set to the same thing every time this code gets executed. You need two different variables for this. If that function is getting called every tick then you need to set the screw_rpm_current to the output of the InterpTo every time it gets called so that the current value is correct and not getting reset to whatever screw_rpm is at the time.
6be418f2ebe2ba1500c0b7c88118f04c39be022d.png

I implemented that in the character BP. I don’t think you can get input mapping events in a UMG BP, so you’ll either need to fire an event or cast to another BP and get the variables. I used the Constant variant so that it’s linear.

Good grief! You are like a personal tutor, do you want to make UE4 tutorial videos on my 2k subscriber 3D modelling and indie game YT channel? lol! You could make serious income off posting tutorials a whole “How do this in Unreal like you would in Unity: Making the switch” series.

Will try that this morning. Thank you.