This might be a silly question, as linear interpolation by definition involves interpolating between two values, but I’m trying to write a function that smoothly moves the player a specific distance in uu (say, 20 units) in a given direction each time it fires. AddMoveInput doesn’t seem right for this, as it can’t control the exact distance, and as I only know the distance traveled, but not the destination, I can’t really lerp between two points- is there any alternative method in UE’s API appropriate for what I’m haphazardly describing?
Could you take your current position say (0,0,0) and just add the 20 to that to get your new destination? So if your character is currently at (0,0,0) and you get input to move to a new location, just get your current location + your move distance (20) and create a new vector (20,0,0) and lerp between these now?
Oh durr, I feel silly for not thinking of that… is there a way to make that work without putting it in tick, though? Ideally I’d like to fire the function once, and trust it to get there.
you have to put this in tick, that’s how you see motions. Unity vector has this thing encapsulated and I think it’s nice, anyway it is a different topic.
like what the guy above says, get a possible destination, and use that to minus your start position, then normalize it, that is your direction for that frame, then multiply it with a speed scalar(a float variable), and then the delta time(to get consistent speed in various framerates). make sure you constantly update you destination.
One problem about lerping is that the moving speed changes based on the distance between to locations, so updating position each frame using direction is a good solution.
Sorry, my other comment made assumptions. What are you trying to do? You want it to move to a location over many frames, or move to a location immediately?
I think you either want SimpleMoveToLocation or UCharacterMovementComponent::MoveSmooth
Doing it this way won’t update the position every frame unless you have it tied to a tick. IDON_EAT_DOGS answer below would be the way I would tackle this if you don’t plan on using the character movement component.