|
| 18 Nov 2012 05:57 AM |
so i want to animate in scripting but idk how to get the coords and the rotation and stuff i want to make a reload animation for my gun i got this already copied from another gun i found on roblox models here is the code(animation)
function ReloadSequence() -- Right Arm Movement(Left/Right,Fowards/Backwards,Up/Down) Rotation(Up/Down,Left/Right,Twist) -- Left Arm Movement(Up/Down,Fowards/Backwards,Left/Rigt) Rotation(Left/Right,Up/Down,Twist) weld33.C1 = CFrame.new(-0.75, -0.6, 0.25) * CFrame.fromEulerAnglesXYZ(math.rad(-90), math.rad(-16), 0) weld55.C1 = CFrame.new(0.9, 0.05, 0.5) * CFrame.fromEulerAnglesXYZ(math.rad(275), 1, math.rad(-0)) wait(.04) weld33.C1 = CFrame.new(-0.75, -0.6, 0.25) * CFrame.fromEulerAnglesXYZ(math.rad(-92), math.rad(-16), 0) weld55.C1 = CFrame.new(0.9, 0.05, 0.5) * CFrame.fromEulerAnglesXYZ(math.rad(280), 1, math.rad(-0)) Tool.Handle.M1:play() Tool.Mag.Transparency = 1 local mag = Tool.Mag:clone() mag.Parent = game.Workspace mag.CanCollide = false mag.Transparency = 0 end
i tried to look at it and tried to understand but i can't understand it |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2012 06:20 AM |
| check the wiki, it'll make you understand everything. |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2012 08:27 AM |
can you send for me a link with the wiki for animating in script? and can you see there how you can get that coordinates fast? |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2012 09:24 AM |
http://wiki.roblox.com/index.php/CFrame http://wiki.roblox.com/index.php/Weld http://wiki.roblox.com/index.php/Welds
to get coordinates fast, go to ROBLOX Studio > Test > Play Solo
in the command bar type this :
left = Instance.new("Weld", game.Workspace.Player1.Torso) left.Part0 = game.Workspace.Player1.Torso left.Part1 = game.Workspace.Player1['Left Arm'] right = Instance.new("Weld", game.Workspace.Player1.Torso) right.Part0 = game.Workspace.Player1.Torso right.Part1 = game.Workspace.Player1['Right Arm']
left.C1 = CFrame.new(x,y,z) * CFrame.Angles(math.rad(x1), math.rad(y1), math.rad(z1))
x is left and right y is up and down z is forward and backward x1,y1 and z1 are rotations (don't ask me to which direction, just test it out.)
to make the actual animation do either one of the following :
1) You set ever coordinate individually and put them after eachother, like this : left.C1 = CFrame.new(x,y,z) * CFrame.Angles(math.rad(x1), math.rad(y1), math.rad(z1)) right.C1 = CFrame.new(x,y,z) * CFrame.Angles(math.rad(x1), math.rad(y1), math.rad(z1)) wait() left.C1 = CFrame.new(x,y,z) * CFrame.Angles(math.rad(x1), math.rad(y1), math.rad(z1)) right.C1 = CFrame.new(x,y,z) * CFrame.Angles(math.rad(x1), math.rad(y1), math.rad(z1))
2) You set a coordinate to where the arm should move, by using a tween function. I have already made one so I'll post it. Usage goes like this :
function tweenC1(weld, cframe, step, delay) local oldp = weld.C1.p local olda = Vector3.new(weld.C1:toEulerAnglesXYZ()) local newp = cframe.p local newa = Vector3.new(cframe:toEulerAnglesXYZ()) tween = function() local loop = coroutine.create(function() for i = 0, 1, step do weld.C1 = CFrame.new((oldp(1-i))+(newp*i) * CFrame.fromEulerAnglesXYZ((olda.x*(1-i)) + (newa.x*i), (olda.y*(1-i)) + (newa.y*i),(olda.z*(1-i)) + (newa.z*i))) wait() end weld.C1 = cframe end) coroutine.resume(loop) end if delay == false then delay(0,tweenfunction) else pcall(tweenfunction) end end
tweenC1(left, CFrame.new(x,y,z) * CFrame.fromEulerAnglesXYZ(math.rad(x1), math.rad(y1), math.rad(z1)), 0.1, true)
false means it waits after tweening. true means it can tween multiple welds at the same time.
Goodluck with it! |
|
|
| Report Abuse |
|
|
|
| 18 Nov 2012 03:17 PM |
if i type that code left=... my arm go away and is in my body and there comes a weld in my torso brick but when i replace my arm it falls down and dissapear |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Nov 2012 03:49 PM |
| You can't just jump into a more complicated scripting subject and expect it to work. I'd start with more simple scripts or actually looking into the source of free-models if I were you. |
|
|
| Report Abuse |
|
|
|
| 22 Nov 2012 09:51 AM |
| i already did but i want to know more about it so i can find the coordinates and stuff you know what i mean? |
|
|
| Report Abuse |
|
|