Im trying to figure out how to simulate recoil on a gun through blueprints and programming instead of having animations and blendspaces.
I tried getting the forward vector of gun and the actors arms and setting their location back and forth between each gunshot. But since there’s no easement or blend time between each set it’s too fast and looks unnatural.
Has anyone here ever done something like this, if so how, or where do I start?
or:
Are animations truly the best way to handle recoil?
Absolutely no answer touching on this topic anywhere in any of the forum, answerhub, or any other site.
Use A for the original straight forward shooting position and B for the “original straight forward shooting position + recoil offset vector”.
After each shot, you calculate the new B vector (looking forward + some random offset ) and you set the blend time back to 0.
On Tick Event, increase the Alpha every frame by deltatime to interpolate from the straight forward vector to the recoil offset vector…
If you directly plug in the DeltaTIme, it’ll take exactly one second to transition from the A vector to the B vector.
If you want to speed it up, just multiply the DeltaTime by some factor to speed it up.
And as the quote says, you can also use lerps for other things like rotators, transformations, etc.
If you don’t want to do it every tick (which could be a waste since you don’t shoot constantly at every frame in the game), you also can use other tools, like a timeline for changing the Alpha from 0 to 1.
hey appreciate the reply. Just saw this today. I dont know why I wasnt more specific in my question. I wanted to accomplish this without using timelines cause I need the time getting from point A to B to be dynamic. But I will look into this delta time thing. I thought it only really worked with vinterp’s but I will try this on the regular lerp. Thanks!