Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i create animations with fromEulerAngles?

Asked by 8 years ago

This is what i have tried

local w = Instance.new("Weld")
w.Part1 = Player.Character:FindFirstChild("Right Leg")
w.Part0 = -- Whatever you're trying to weld to the right leg.
w.C0 = CFrame.new(-0.65, -0.25, 0) * CFrame.fromEulerAnglesXYZ(math.rad(25), 0, 0)
w.C1 = CFrame.new() -- Also not sure why this line is here.
w.Parent = -- Whatever you're trying to weld to the right leg
2
CFrame.Angles is a much shorter name for CFrame.fromEulerAnglesXYZ btw BlueTaslem 18071 — 8y

1 answer

Log in to vote
3
Answered by 8 years ago

'C0' is where an imaginary offset point is placed relative to 'Part0'. 'C1' is how 'Part1' is attached to that offset point, angle and all.

Welds

If you're animating the typical actor (two arms, a torso, a couple of legs, and a head) you should try using ROBLOX's animation plugin or Davidii's(or was it Daviidi) expansion of it, but if you're serious on making custom 'frames' (which could be useful for actors that aren't the typical character) then you'd have to make a table or list of every joint's desired weld CFrames per frame. At least, this is how I would try it. I've never used CFrame to animate as it seems beyond tedious to me. This being the case, I'll leave my code abstract for your interpretation.

--[[
So if you want to have a joint per limb on a character, you already have the pre-defined joints from ROBLOX:
"Neck"
"Right Hip"
"Left Hip"
"Right Shoulder"
"Left Shoulder"
These aren't welds, but rather 'Motor6D' s.  I'm not sure how they completely work, but I assume they're a mix of 'Motor's and 'Weld's and they have Part0s, Part1s, C0s, and C1s so we can cframe them! 
Each index of the joint tables will be a different frame.  I use short hands for the table names.
]]--

--Joints to refer to!
N = FIND MY NECK! 
RH = FIND MY RIGHT HIP!
LH = FIND MY LEFT HIP!
RH = FIND MY RIGHT SHOULDER!
LH = FIND MY LEFT SHOULDER!

--Tables that contain our animation frames!
tN = {
    Neck CFrame in frame 1,
    Neck CFrame in frame 2
}
tLH = {
    Left Hip CFrame in frame 1,
    Left Hip CFrame in frame 2
}
tRH = {
    Right Hip CFrame in frame 1,
    Right Hip CFrame in frame 2
}
tLS = {
    Left Shoulder CFrame in frame 1,
    Left Shoulder CFrame in frame 2
}
tRS = {
    Right Shoulder CFrame in frame 1,
    Right Shoulder CFrame in frame 2
}
--Now that our desired CFrames per joint are pre-set in tables... Animate!
function animate(frame)
    N.Weld.C1 = tN[frame]
    RH.Weld.C1 = tRH[frame]
    LH.Weld.C1 = tLH[frame]
    RS.Weld.C1 = tRS[frame]
    LS.Weld.C1 = tLS[frame]
end

--Why not run our animation in a loop?  Don't do this unless for testing purposes.  I abhor infinite loops.
framespersecond = 1 
frames = #tN --Assuming all tables of each joint have the same amount of 'frames' I just grabbed the number of frames associated with 'Neck' so we can iterate through all of them.
while true do
    for i = 1, frames do
        animate(i)
        wait(framespersecond)
    end
end

If I made any typos or was completely useless please tell me so I can edit/remove this answer.

EDIT: tN.[frame] should've been tN[frame] fixed!

0
dedicated typing. voting him up ^_^ DragonODeath 50 — 8y
Ad

Answer this question