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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 20 Nov 2008 |
| Total Posts: 1227 |
|
|
| 12 Jan 2014 03:46 PM |
| aha! Thanks TheLuaWeaver, there's another great formula. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Jan 2014 04:00 PM |
| @WebGL, math.pi is 180 degrees |
|
|
| Report Abuse |
|
|
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 |
|
|