How can I get the “CFrame” track of my Moon Animator anims to work in game? And another thing: How do I make it such that the CFrames are proportional to a character model’s position?
Here I’ve added a points of all the CFrame values I’ve nabbed from the Moon Animator saves.
Red points are the points the player’s model will be moved to (AnimDummy2)
Blue points are the points the NPC’s model will be moved to (AnimDummy)
Issue: Making the frames proportional to where a model currently is.
sorry if this post isnt phrased well
Edit: made some code changes
for i, v in pairs(sequence.Rigs) do
local model = v["Model"]
local CinematicsFolder = sequencemod.RigFrames:FindFirstChild(i)
local FrameTime = 0
local Connection
local animator = model:FindFirstChild("Animator", true)
local anim = GameplayModule.loadanimation(animator, v["Track"])
anim:Play()
local cinematicarray = CinematicsFolder:GetChildren()
local function sort(a,b)
if tonumber(a.Name) < tonumber(b.Name) then
return true
end
end
table.sort(cinematicarray, sort)
local previoustiming = 0
local mover = coroutine.create(function()
for i2, v2 in pairs(cinematicarray) do
model.HumanoidRootPart.Anchored = true
if i2 == 1 then
model.HumanoidRootPart.CFrame = v2.Value
else
local nextpos = cinematicarray[i2 + 1]
if nextpos then
local waitframe = tonumber(nextpos.Name) - previoustiming
local info = TweenInfo.new(waitframe/120, Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local goal = {CFrame = v2.Value}
local tween = TweenService:Create(model.HumanoidRootPart,info,goal)
tween:Play()
wait(waitframe/120)
end
end
previoustiming = tonumber(v2.Name)
end
model.HumanoidRootPart.Anchored = false
return
end)
coroutine.resume(mover)
end
code sample update. Need some help with cframe handling. See reply.
Best solution i can think of is animating it at 0,0,0, then the cframe values moon pumps out are basically offsets, from there you can simple set positions by using character:GetPivot() * AnimationCframe.
I am generally against the idea of using cframe in moon though, usually ill move the character to the end position beforehand in gameplay code, and just animate the character getting hit to that spot
Got this solved recently, just forgot to update the thread.
this code loops through a table of rigs i have.
This is the farthest I managed to go without altering the CFrameValues.
This probably isnt the best way to do it, but this is works mostly fine.
This could however make the frames of the main rig go in the opposite direction of its intended cframe.
So i had to go into the folder, flip it around 180 degrees, then it managed to look normal.
startframe is the start of the cframe track of the current rig
mainstartframe is the start of the cframe track for the main rig (basically the rig where everything is proportional to)
local previoustiming = 0
local mover = coroutine.create(function()
for index, value in pairs(cinematicarray) do --cinematic array refers to the folder with the cframevalues
frame = tonumber(value.Name)
local difference = startframe.Value:Inverse() * mainstartframe.Value -- offset the current rig is from the main rig
local destinedframe = (currentpoint * difference) * (value.Value * startframe.Value:Inverse())
model.HumanoidRootPart.Anchored = true
if index == 1 then
model.HumanoidRootPart.CFrame = destinedframe
else
local nextpos = cinematicarray[index + 1]
if nextpos then
local waitframe = tonumber(nextpos.Name) - previoustiming
local info = TweenInfo.new(waitframe/120, Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local goal = {CFrame = destinedframe}
local tween = TweenService:Create(model.HumanoidRootPart,info,goal)
tween:Play()
wait(waitframe/120)
end
end
previoustiming = tonumber(value.Name)
end
model.HumanoidRootPart.Anchored = false
return
end)
coroutine.resume(mover)