Soo the following code has an issue its called from a function and it will only work if you are moving but once u stop it stops working all together. its just a simple recoil code bit that just move the arms back a tiny bit. i even tried this in world space with same results. is there something wrong with this line of code for it to not be called every time the function is called?
FVector* tempVector = new FVector(0,0,0);
tempVector->X = ArmsBasePostion.X + Recoil;
FPSArms->RelativeLocation = FMath::VInterpTo(ArmsBasePostion, FVector(tempVector->X, ArmsBasePostion.Y, ArmsBasePostion.Z), GetWorld()->DeltaTimeSeconds, 5);
Where is this being called from?
Side note: I’m not sure why you’re using a pointer to an FVector but make sure you delete it when you’re done with it. IMO you really shouldn’t be using ‘new’ there at all tho, for performance reasons.
VInterpTo needs the first parameter to be set to the result it returns so the next time it can get closer. Are you doing that? You might be getting confused with Lerp, which takes start and end with an alpha. The interp-to functions take the current and end with the time-elapsed.
Also, you could try writing the vector to the log and see what the numbers are doing. It might give insight into the problem.
For my recoil I used a timeline to drive an offset for the hand location. I use the timeline output as the alpha of a lerp. Just throwing it out there as an alternative.
oo thanks yeah the “new” thing is a old habit from unity. the Vinterpto is being called from a function. which is called from a timer. which is in a function. which is set to a input delegate and is called every time i fire. the whole function runs fine except this interp. i took it out and tested it in a tick with a bool to turn it off and on, to see how it would react and got same issue only working when moving.
nah i fixed it. one of those duh moments where you for get to change your temp code to real code. i had the arm reset set to just setting the arm base instead of a interpto to reset it back which would allow for the arms to ease back to its position which gives it a natural and more realistic recoil.