Why the GetKillsAsText binding?

For the health, I understand that we need a function because we need to convert from the [0-100] range to a percentage ([0.0-1.0] range).

For the kills however, I could just bind the widget directly to the Marine.Health property that show up in the binding dropbox.

Is this because it’s a recent feature that didn’t exist at the time of the recording (I’m using 5.0.3)? Or is there some other reason that makes it inadvisable?

Encapsulation is when your provide a function to access the data/variable within the same “unit” as the variable. In this particular case, it would be encapsulation if the Marine blueprint was providing the “GetKills” function.

As-is, that GetKills is in the same “unit” as the rest of the UI, i.e. it’s still in the HUD blueprint, albeit the “Graph” part rather than the “Designer” part.

Sometimes it’s useful to show that there are multiple ways of doing the same thing.

Your example works for something simple like kills and has been around in UE4 before the course was created.

Though, from a teaching perspective, using the GetKills function is easier for showing what’s going on.

There’s no need to delete you comment mate. Your input was still valuable. :wink:

Indeed, but that would be an argument for showing that you can bind a property directly, since the same lecture already shows the use of a function to get the health :wink:

On a different but mostly related note, do you know how to show a function in the list (like the GetAnimRootMotionTranslationScale in the screenshot above)? Why does that one show there but none of the functions that were added to the blueprint during the course

There are two conditions for having functions show up.

  1. The return node matches what the binding expects

  2. The function must be pure

1 Like

Hmm, that’s odd…

I do get that the function to show if I make it return a Text type (GetKillCount in the screenshot below), but it doesn’t work if I make it return an Int or a Float or even a String, which is in line with what you said.

However GetAnimRootMotionTranslationScale returns a float and shows up in the list anyway, and when looking at the component parts of Marine (e.g. the Rifle), I do see plenty of float and integer functions (see screenshot below)


.

I suspect that Epic is doing something fancy with their own stuff or that there’s additional details to making this work that I don’t know about.

But from my own quick experimentation I sussed out the two conditions I mentioned before.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms