I’m trying to use procedural animation to create a combat system, for now I’m attempting to simply animate it before throwing it all into a full fledged system however I’m having trouble with the code below.
Essentially the arm moves to a weird initial keyframe behind the player rather than just moving on the joint. I’m unsure how I’d solve this.
Gif showing problem: https://gyazo.com/1bb5d73f92262b3ea54d781e1261acb2
( Don’t mind the way the arm faces backwards, it’s intentional to test )
local TweenService = game:GetService("TweenService")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Character)
SwordProceduralM11(player, Character)
end)
end)
function SwordProceduralM11(Player, Character)
local CFrameValue = Instance.new("CFrameValue")
local SavedBaseCFrame = Character.Torso["Right Shoulder"].C0
local Goal = {}
CFrameValue.Changed:Connect(function()
Character.Torso["Right Shoulder"].C0 = CFrameValue.Value
end)
wait(5)
local TweenSettings = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
Goal.Value = SavedBaseCFrame * CFrame.Angles(math.rad(0), math.rad(0), math.rad(90))
local tween = TweenService:Create(CFrameValue, TweenSettings, Goal)
tween:Play()
end