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: CFraming

Previous Thread :: Next Thread 
VoltiCoil is not online. VoltiCoil
Joined: 20 Nov 2008
Total Posts: 1227
12 Jan 2014 03:37 PM
Hi everyone. I want to create a script that rotates a brick every second by 90 degrees. Now this is quite simple, I know.

script.Parent.Countdown.Changed:connect(function()

script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0,90,0)

end)

But how would I get the brick to move as if it were animated. Not instantly hit 90 degrees but as if it was turning into the 90.

I tried this method:

for i = 1,90 d0

wait(0.01)

script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0,i,0)

end

But that spins the block far more than 90 degrees within a second.

I just want it to "turn" into position as if a corner of it were to be pushed. Not instantly 90 degrees and not mad spinning as it had done for a whole second.

Thanks for the help!
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 Jan 2014 03:38 PM
math.rad(90)
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
12 Jan 2014 03:40 PM
CFrame.Angles uses radians, as cntkillme said you can use math.rad(degree) to get 90 degrees in radians, another way to do it would be math.pi :P
CFrame.Angles(0,math.pi,0)


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
VoltiCoil is not online. VoltiCoil
Joined: 20 Nov 2008
Total Posts: 1227
12 Jan 2014 03:42 PM
oh no no no. I know all that. Those methods rotate the brick 90 degrees withing a split second. What do you take me for boss? ^_^

I want the brick to spin 90 degrees in 0.5 of a second. Not instantly rotate. It has to be as if there was an animation about it.
Report Abuse
TheLuaWeaver is not online. TheLuaWeaver
Joined: 09 Feb 2010
Total Posts: 1504
12 Jan 2014 03:43 PM
WebGL, that is wrong. math.pi=180 degrees, so math.pi/2=90 degrees.

Anyways, to "animate" it, just use a for loop.

for i=0,math.pi/2,math.pi/90 do
workspace.Part.CFrame=CFrame.new(workspace.Part.CFrame.p)*CFrame.Angles(0,i,0)
wait()
end

~LuaWeaver; Programmer, gamer, developer.
Report Abuse
VoltiCoil is not online. VoltiCoil
Joined: 20 Nov 2008
Total Posts: 1227
12 Jan 2014 03:45 PM

for i = 1,90 do

script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0,math.rad(i),0)
wait(0.01)

end

is another way. Sorry, just figured this one out ^_^
Report Abuse
VoltiCoil is not online. VoltiCoil
Joined: 20 Nov 2008
Total Posts: 1227
12 Jan 2014 03:46 PM
aha! Thanks TheLuaWeaver, there's another great formula.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 Jan 2014 04:00 PM
@WebGL, math.pi is 180 degrees
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
12 Jan 2014 04:28 PM
I knew that xP
Tried to fix it, got flood checked, and had to go cook lol
math.pi/2


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
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