Requesting Assistance In With Controlling Lerp Node

Alright, so, I’ve been recreating a Unity project in Unreal since the business change Unity had announced, and while working on an Auto Aim system, I’ve ran into an issue I cannot resolve.

It should be noted, that mechanically, it works perfectly. What I’m having trouble producing is the weapon view model smoothly moving from the center of the screen to the target, then back to the center.

Here is the results I had in Unity, what I’m trying to replicate: https://i.imgur.com/5FaF1ua.mp4
And here’s what I have in Unreal: https://i.imgur.com/cLIYStx.mp4

Here are the blueprint nodes I have for the auto aim system: https://i.imgur.com/znqYelB.png (Forgive the mess, I had to condense the nodes to fit them in a screenshot.)

‘Auto Aim Collision’ is a collision component checking what is touching it.
‘Weapon’ is the component that projectiles come from (I.E., it instantly locks on to targets and returns to the center).
‘Weapon Model’ is the view model that smoothly moves between the center of the screen and the target.
All of three of these components are children to the Camera.

The issue is I am unable to figure out how to get the Weapon Model to stop Lerp-ing once it returns to the center of the screen.

I think the issue is the fix alpha value and that might be why the lerp is not moving correctly (or too fast)

You should add a continuous value to the alpha lerp respective to time:

Either with a Timeline, function timer or a manual loop with delay incrementing the alpha value from 0.0 to 1.0

For example Delay +0.1s , will increment alpha value by +0.1.

I attempted to experiment with the suggestions you provided and didn’t get any desired results. Though I won’t throw out the possibility that it was because of me not fully understanding how to properly impliment the suggestions.

Perhaps my conclusion that it was a problem with the Lerp node was incorrect. Cause the result I’m wanting is the Weapon Model component to smoothly return to its default rotation and then stop trying to follow back to that point.

Originally, I had thought that adjusting the relative rotation would do the trick, but doing so gave me results like this: https://i.imgur.com/rXc8atS.mp4

So then, working with world rotation, I concluded that the Lerp was fine up until the camera moved and the Auto Aim Collision had no valid target, which lead me to the idea of trying to stop the Lerp node when these conditions were met.

One of the attempts involved a float acting as the Lerp alpha, which would set to 0.1 when a valid target was found, and when there was no target, it would have its own Lerp node to reach 1 in a short amount of time, which was fine until noticing jittering as the alpha float was nearing 1. Another attempt was having an Equal node saying to set the float value to 1 if the Weapon Model Rotation was equal to the Target Direction, but even with an error tolerance, I couldn’t get something that matched what I wanted.

Try with something like that to stop the lerp:

Thanks for the continued assistance. While this suggestion hadn’t given me the result I was after, it did give me an idea, and I ended up getting something I wanted with a very simple solution.

Occam’s Razor, and that sort of thing. After an Alpha float would go past a certain point, the speed it approaches 1 would increase with an additional addition node.

So thank you again!

1 Like

glad you made it :innocent:

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