Recoil Patterns

Can someone tell me how to code Recoil Patterns? I don’t know how to do it so any help is greatly appreciated.

Hi @projectvexxed,

For simple offset from cursor recoils on a straight line you can use the pc.Vec3.lerp method. Basically when the weapon fires you offset the current cursor/model position by a value and use lerp to move it up/down. Using time based inertia as the lerp alpha value.

https://developer.playcanvas.com/en/api/pc.Vec3.html#lerp

For more complex recoil patterns that use special curves you can use the pc.Curve object. A good example is the following doing camera animation.

https://developer.playcanvas.com/en/tutorials/camera-following-a-path/