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 » Scripters
Home Search
 

Re: Orbiting a part around another resets the part's orientation

Previous Thread :: Next Thread 
huner2 is not online. 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 is not online. 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 is not online. huner2
Joined: 27 Apr 2008
Total Posts: 1681
06 Mar 2015 07:29 PM
Bump

~I've got one in my closet~
Report Abuse
Spirographic is not online. Spirographic
Joined: 17 Aug 2007
Total Posts: 19084
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 is not online. 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 is not online. 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
Spirographic is not online. Spirographic
Joined: 17 Aug 2007
Total Posts: 19084
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 is not online. 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
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
06 Mar 2015 07:44 PM
http://www.roblox.com/Forum/ShowPost.aspx?PostID=125276658

Maybe that'll help.
Report Abuse
huner2 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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