Archive 17/01/2023.

Recoil simulation

burt

Just saw this cool video: https://www.youtube.com/watch?v=Giuoq786gP0

Does anyone have any idea what he is using here? Just some random noise on the weapon root bone?

suppagam

Seems like the https://en.wikipedia.org/wiki/Lissajous_curve ?

Leith

I’d go with random torque, resulting in compound angular error, and a motor sluggishly pulling the orientation back toward the aim constraint, like a slow spring… but I sense it’s not that random… the right “feel” would include the angular momentum at the moment of firing.

suppagam

Could you elaborate a little bit on “compound angular error” and “random torque”? By random torque, you mean pushing the model randomly in the horizontal and vertical axis over delta time? Like, model.x = model.x * rand(1, 50) * delta.Time?

Leith

I was actually thinking in spherical terms - something akin to arcball rotation, but a 2D version would involve choosing a vector which points away from the target in a direction which is initially random, but which tends in the direction of any existing offset, and with a random (but clamped) magnitude. This vector can be used to compute a new lookat vector, which we lerp toward fairly rapidly, while a spring equation can be used to pull the newly-calculated lookat vector back to point at the target over time.
The concept I had in mind is that initially we choose a random directional error term, but should the player shoot again, the new direction should strongly reflect the existing direction error term - and this whole notion of angular error terms should definitely be clamped to reasonable angular limits…