-
What do you want to achieve? Keep it simple and clear!
I want to move the character’s arms with the gun so that you can aim down the barrel kind of like shooters such as Phantom Forces. -
What is the issue? Include screenshots / videos if possible!
I need to properly align the arms with the gun when going in and out of aim down sights. The best that I could achieve is it properly aligning every other time it is ran, however that will not work as it will be zoomed in and out every other time once complete.
https://gyazo.com/8b7375473bce58e53d30c3560bf81125 -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried changing the positional components of the offset to negative or positive but have not found luck. I’ve also tried modifying the equations that find the offsets, but this is the best that I could do myself (Code below). I know that saving the C1 value of the arms when they’re properly aligned would solve this, but a universal solution (If possible) would be preferable as this function will be used with a variety of guns. Thank you for your time.
function WeaponModule:Aim()
local MOffset = self.Tool.Model.Motor6DAttachment.CFrame:ToObjectSpace(self.Tool.Model.Aim.CFrame)
local MGoal = self.Weapon6D.M6D.Transform * MOffset
local ROffset = self.Character["Right Arm"].CFrame:ToObjectSpace(self.Tool.Model.Motor6DAttachment.CFrame)
local RGoal = CFrame.new(-MGoal.Position - ROffset.Position)
local LOffset = self.Character["Left Arm"].CFrame:ToObjectSpace(self.Tool.Model.Motor6DAttachment.CFrame)
local LGoal = CFrame.new(-MGoal.Position - LOffset.Position)
local AimTweenInfo = TweenInfo.new(self.AimTime, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
TweenService:Create(self.Weapon6D.M6D, AimTweenInfo, {["C1"] = MGoal}):Play()
TweenService:Create(self.RightShoulder.M6D, AimTweenInfo, {["C1"] = RGoal}):Play()
TweenService:Create(self.LeftShoulder.M6D, AimTweenInfo, {["C1"] = LGoal}):Play()
end