generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: i want to animate in scripting

Previous Thread :: Next Thread 
shouldbeperfect is not online. shouldbeperfect
Joined: 25 Sep 2011
Total Posts: 48
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
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
18 Nov 2012 06:20 AM
check the wiki, it'll make you understand everything.
Report Abuse
shouldbeperfect is not online. shouldbeperfect
Joined: 25 Sep 2011
Total Posts: 48
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
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
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
shouldbeperfect is not online. shouldbeperfect
Joined: 25 Sep 2011
Total Posts: 48
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
shouldbeperfect is not online. shouldbeperfect
Joined: 25 Sep 2011
Total Posts: 48
21 Nov 2012 03:22 PM
bump
Report Abuse
EchoReaper is not online. EchoReaper
Joined: 14 Oct 2008
Total Posts: 4323
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
shouldbeperfect is not online. shouldbeperfect
Joined: 25 Sep 2011
Total Posts: 48
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image