huner2
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 1681 |
|
|
| 06 Mar 2015 06:32 PM |
I feel like my other post was worded weirdly, so yeah.
I have a part m1.Top that orbits around part orange. This works fine, the only problem is that instead of maintaining the rotation it had before the orbit starts, it resets the rotation of m1.Top.
How can I fix this problem?
Code:
for i = 1,180 do wait() m1.Top.CFrame = CFrame.new(orange.Position) * CFrame.Angles(0, math.rad(i*2), 0) * CFrame.new(0, 0, (orange.Position - m1.Top.Position).magnitude) end
~I've got one in my closet~ |
|
|
| Report Abuse |
|
|
huner2
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 1681 |
|
|
| 06 Mar 2015 06:51 PM |
Bump
~I've got one in my closet~ |
|
|
| Report Abuse |
|
|
huner2
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 1681 |
|
|
| 06 Mar 2015 07:29 PM |
Bump
~I've got one in my closet~ |
|
|
| Report Abuse |
|
|
|
| 06 Mar 2015 07:33 PM |
you need to store m1's rotation matrix or euler angles in a variable before running the code and then call it to multiply the cframe by the stored angles
as such,
local stAng=m1.CFrame:toEulerAnglesXYZ()
for i = 1,180 do wait() m1.Top.CFrame = CFrame.new(orange.Position) * CFrame.Angles(0, math.rad(i*2), 0) * CFrame.new(0, 0, (orange.Position - m1.Top.Position).magnitude) * stAng end
I didn't test this myself, but it should do the trick. |
|
|
| Report Abuse |
|
|
huner2
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 1681 |
|
|
| 06 Mar 2015 07:37 PM |
Error:
Workspace.Door.Script:45: bad argument #2 to '?' (Vector3 expected, got number)
~I've got one in my closet~ |
|
|
| Report Abuse |
|
|
huner2
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 1681 |
|
|
| 06 Mar 2015 07:37 PM |
Which is for the m1.Top.CFrame line.
~I've got one in my closet~ |
|
|
| Report Abuse |
|
|
|
| 06 Mar 2015 07:41 PM |
Ah, yes, I'm a moron.
Change
local stAng=m1.CFrame:toEulerAnglesXYZ()
to
local stAng=m1.Top.CFrame:toEulerAnglesXYZ() |
|
|
| Report Abuse |
|
|
huner2
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 1681 |
|
|
| 06 Mar 2015 07:43 PM |
I already did that change, still getting the same error.
~I've got one in my closet~ |
|
|
| Report Abuse |
|
|
|
| 06 Mar 2015 07:44 PM |
http://www.roblox.com/Forum/ShowPost.aspx?PostID=125276658
Maybe that'll help. |
|
|
| Report Abuse |
|
|
huner2
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 1681 |
|
|
| 06 Mar 2015 08:24 PM |
It expanded my thoughts a little, but didn't help, I tried implementing bits and pieces and it ended up not being even close.
~I've got one in my closet~ |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 06 Mar 2015 08:31 PM |
Just save the old rotation? local old = m1.Top.CFrame - m1.Top.Position;
Multiply that with the new matrix from doing CFrame.new(oranage.Position) |
|
|
| Report Abuse |
|
|
huner2
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 1681 |
|
|
| 06 Mar 2015 08:33 PM |
Did it.
local x,y,z=m1.Top.CFrame:toEulerAnglesXYZ() for i = 1,180 do wait() m1.Top.CFrame = CFrame.new(orange.Position) * CFrame.Angles(0, math.rad(i*2), 0) * CFrame.new(0, 0, (orange.Position - m1.Top.Position).magnitude) * CFrame.Angles(x,y,z) end
~I've got one in my closet~ |
|
|
| Report Abuse |
|
|