UE 4.7 - get distance to - How to change funtion to unpure

Hi

Since 4.7 function “get distance to” has no execution pin. This is caused by this change which I have found in changelog:

New: When blueprint functions that
change from impure to pure, the
execution pins in the graph will
automatically update to maintain the
execution flow.

Several Actor class
functions became pure (Get Distance
To, etc.)

Problem is I used that funtion for major feature in my game, so now I will have to find workaround.
Is there a way to change this funtion locally to unpure (with execution pins) through C++?

Sorry to hear this is causing you issues.
Can you provide more information on how this change has broken your use case?

Is it that it didn’t properly connect the execution pin in the fixup?
Or is something else going on?

With some more information I hope we can resolve this for you.

You could simply create a function (perhaps in a BP function library) that encapsulates it.

I just encountered this myself. When I create “get distance to” there are no execution pins. Is there a way to fix this on my end? Help is greatly appreciated!

Why you need execution pins on “get distance to”?

Hi Chris

I have found a workaround for that. I attached screenshots from 4.6 and 4.7. As you can see in 4.7 I had to make more scripting to achieve same result. The goal is to get constantly distance between player and point, with certain small intervals.

Yes, but how ? :slight_smile:

Just create a new function with the same inputs and outputs as the original. Pass the function’s inputs into the pure function and the pure function’s output into your function’s output.

To create a function library, right click in your assets, scroll down to blueprints, and in the new menu, click function library.

I understand how this change affected you now, thanks for the report.

You have already figured out how to cache the values to accomplish the desired behavior. That is the correct way to do it.

Here is an example of how that might be done that is slightly simpler.

In general I would not use a delay in that code.
For clarity i would make a function that looked something like this:

32605-updatefunctionbasedonlastupdate.png

It may very well be the case that you call this function every frame, or use a delay in some other code to only call it once a second.
That may look like:

Hopefully this is helpful.