Converting Blueprint to C++

some things work better in C++ (better performance, more strict dependencies, and closer to single execution assembly after compile)

there are some things that actually do worse in C++:
Most of these boil down to “specific references should live in blueprints” otherwise we get into “Runtime resolved Hard References” (these have a bunch of problems for more detailed reading StaticLoad problems - failing to find file - #2 by anonymous_user_4fe9f58b1)

  • anything that needs specific data defined in blueprints, will need some intermediary in a BlueprintNative or BlueprintImplementable or such.
  • needing to instantiate a specific blueprint see above.
  • many parts of Enhanced input setup (the functions that are run can still be done in C++ but assigning the content browser stuff is better off through blueprints)
  • shaders (the days of manually writing shader scripts are luckily very rare)
  • animations (technically state trees in general) but this is mostly to do with the next part
  • timelines: there are work around for this but they might not be pretty.

for things with timelines the biggest reason to do these in blueprints is you get a graph with points you can move around on that graph, and maybe even modify curve slope. the alternative in C++ is manually managing state through some kind of enum/int, and then making functions of (float deltaT). and probably involving Tick (it is mostly blueprints that gives Tick the bad name, but Tick is not the problem directly)

for this specific situation if you want to move forward moving it into C++ an implementation would be have a state variable (enum or int) then in Tick() check the state variable and do your modifications to what I am presuming is the transform.
where the slope is Linear then you have a bit of luck where FMath::Lerp() is already defined (there are defined flavors of Slerp as well but those are more specific)

the signature on Lerp might be intimidating but

FVector NewLocation = FMath::Lerp(GetLocation(), TargetLocation(), DeltaTime);

though this might require a check for if you have arrived at the destination with a “more meaningful” (GetLocation() == TargetLocation)

if you want parabolic behavior (easing) you might consider like FMath::VInterpTo().