Thank you so much! Also, my code was slightly misleading. I’m setting OriginalPosition earlier. Let me lay it out in more detail.
OriginalPosition = Location;
inited = true;
Target = Vect(100, 0, 0);
MoveVector = VInterpTo((Location-OriginalPosition), Target, DeltaTime, ?????);
Move (and MoveSmooth) are relative to (current) Location, so I needed to work out where, exactly, I was in relation to the target location.
I could equally have done (I think)
Target = OriginalPosition + Vect(100, 0, 0);
MoveVector = VInterpTo(Location, Target, etc, etc
MoveSmooth(MoveVector - Location);
But, ok, two questions.
- Where did you find the code for VInterpTo. It’s defined as native, so I couldn’t dig deeper, and didn’t find it anywhere on the net. I’d love to be able to dig at this stuff for myself, rather than hassling you or others.
- If I understand the function correctly, let me break out a specific example.
Let’s assume we’re getting 10 frames per second, so DeltaTime is always 0.1 and InterpSpeed is set to 1.
DeltaMove = Dist * FMath::Clamp<float>(DeltaTime * InterpSpeed, 0.f, 1.f);
DeltaMove = (100-0) * 0.1 * 1 = 10
0.2: (100-10) * 0.1 * 1 = 9
0.3: (100-19) * 0.1 * 1 = 8.1
0.4: (100-27.1) * 0.1 * 1 = 7.29
0.5: (100-34.39) * 0.1 * 1 = 6.561
And so on. So, actually, it’s just inverse exponentially crawling towards the target, and will take (literally) forever to get there.
Can I ask how you’re cooking your own? I’d love to grab hold of something. I’m basically trying to smooth stuff in and out. I’ve tinkered with InterpCurves, but when I apply CIM_CurveAuto, I get massively slowdowns around the curves, even with a few simple points, so I’ve settled on 3x^2-2x^3 which is a clumsy easeinout (Graph Link) for values between 0 and 1.
Ultimately, I’m totally rubbish at animating, and trying to procedurally generate a VTOL aircraft hovering, so throwing a random 100 vector at it every couple of seconds, and having it move around in that fashion (with appropriate pitch and yaw and roll thrown in). It’s ok, but it’s not great. I started to get somewhere with VInterpTo, but only because I threw in a couple of random seeds on each tick to knock it the other way. I’m sure there’s better way.
I’m now thinking I generate a sphere in which it can move, and the closer it is to the centre, the more it can move outwards each tick (individually calculated across three planes), but that starts to get computationally heavy. Any thoughts you have would be most welcomed.