I tried to recreate this feature in my project, and i think I’m almost there, but I really don’t know how to work with positions and CFrames, so it doesn’t work as i intended, and i don’t know what to do.
Basically, I’m just raycasting from character’s head, and if there is some obstacle, then we subtract the position of the player’s arm from the position of the wall, and we add this difference to the Z coordinate of the shoulder’s Motor6D.
I lack knowledge in how the positions and CFrames work, so I would appreciate if someone tells me the correct way how this feature is should be made.
local ray = workspace:RayCast(Camera.CFrame.Position, Camera.CFrame.LookVector*5.5) -- remember to filter out stuff with raycast params
local Pushback = CFrame.new(0,0,ray.Distance-2) -- Subtract distance from gun length (you can tweak the gunlength value here to reach desired effect) if its reversed just absolute the number via math.abs() or invert it with (-), for smoother effect you could lerp the CFrame
This is what we use in The Eastern War. If you have a question u can dm me trough the MPS comms server (4ce)