#Adding a weapon sway
1 messages · Page 1 of 1 (latest)
Hi, it depends a lot on the asset you are working with, is it the FPS Animation Pack or the FPS Animation Framework?
This is an fps animation pack
Okay, so you can write your own sway calculation logic, and then apply the final value to the ik_hand_gun bone in Late Update - this bone controls the weapon and hands poses. You'll also need to insert that logic in the FPSPlayer or Procedural Animation scripts, depending on what exactly you are using
You need to place that logic inside the FPS Player or Procedural Animation component, I suggest taking a look at how it's implemented in the Late Update method
Now there are some very strong twitches
This will not work, because transform is updated every single frame, so it won't be accumulated. Instead, you need to create a variable, call it _swayRotation and then modify it instead. Finally, accumulate the rotation result: transform.rotation *= _swayRotation
Also, do not use the Slerp function this way. Instead, use this code snippet:
float alpha = KMath.ExpDecayAlpha(interpolationSpeed, Time.deltaTime);
_swayRotation.rotation = Quaternion.Slerp(_swayRotation, targetRotation, alpha);
transform.rotation *= _swayRotation;